24 class save_index_class;
33 const std::shared_ptr<save_index_class>&
index,
34 const std::chrono::system_clock::time_point&
modified)
42 const std::string&
name()
const
72 void read_save_file(
const std::string& dir,
const std::string& name,
config& cfg, std::string* error_log);
101 void rebuild(
const std::string& name);
102 void rebuild(
const std::string& name,
const std::chrono::system_clock::time_point& modified);
105 void remove(
const std::string& name);
106 void set_modified(
const std::string& name,
const std::chrono::system_clock::time_point& modified);
109 const std::string&
dir()
const;
135 std::map<std::string, std::chrono::system_clock::time_point>
modified_;
A config object defines a single node in a WML file, with access to child nodes.
std::shared_ptr< save_index_class > manager_
save_info operator()(const std::string &filename) const
create_save_info(const std::shared_ptr< save_index_class > &)
void clean_up_index()
Deletes non-existent save files from the index.
create_for_default_saves_dir
Syntatic sugar for choosing which constructor to use.
static std::shared_ptr< save_index_class > default_saves_dir()
Returns an instance for managing saves in filesystem::get_saves_dir()
std::vector< save_info > get_saves_list(const std::string *filter=nullptr)
Get a list of available saves.
void remove(const std::string &name)
Delete a savegame from the index, without deleting the underlying file.
bool read_only_
The instance for default_saves_dir() writes a cache file.
void write_save_index()
Sync to disk, no-op if read_only_ is set.
const std::string & dir() const
config & get(const std::string &name)
void set_modified(const std::string &name, const std::chrono::system_clock::time_point &modified)
void delete_old_auto_saves(const int autosavemax, const int infinite_auto_saves)
Delete autosaves that are no longer needed (according to the autosave policy in the preferences).
bool read_only()
If true, all of delete_game, delete_old_auto_saves and write_save_index will be no-ops.
void delete_game(const std::string &name)
Delete a savegame, including deleting the underlying file.
void rebuild(const std::string &name)
std::map< std::string, std::chrono::system_clock::time_point > modified_
save_index_class(const std::string &dir)
Constructor for a read-only instance.
bool clean_up_index_
Flag to only run the clean_up_index method once.
static void fix_leader_image_path(config &data)
Filename and modification date for a file list.
save_info(const std::string &name, const std::shared_ptr< save_index_class > &index, const std::chrono::system_clock::time_point &modified)
const std::string & name() const
const config & summary() const
std::string format_time_local() const
std::string format_time_summary() const
std::shared_ptr< save_index_class > save_index_
std::chrono::system_clock::time_point modified_
const auto & modified() const
Definitions for the interface to Wesnoth Markup Language (WML).
void read_save_file(const std::string &dir, const std::string &name, config &cfg, std::string *error_log)
Read the complete config information out of a savefile.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
std::string filename
Filename.
A structure for comparing to save_info objects based on their modified time.
bool operator()(const save_info &a, const save_info &b) const