dao::saves::Slot

struct

One save slot of one character.

Declared in dao/Saves.h.

Functions

Exists()

bool Exists() const

Returns whether the slot holds a save, that is, a .das file in its folder.

File()

std::filesystem::path File(std::string_view plugin) const

Returns the path of this plugin’s file in the save, <slot folder>\<plugin>.daolib, for a plugin that would rather stream it.

Folder()

std::filesystem::path Folder() const

Returns the slot’s folder, for example <documents>\BioWare\Dragon Age\Characters\<character>\Saves\Slot_<n>.

The path comes from the game itself, so it is right wherever the game keeps its saves.

Meta()

std::optional<core::SaveMeta> Meta() const

Reads the save’s metadata from its .das.met file: what the load screen shows, such as the area, the time played, the character’s level and the save’s name.

Returns the metadata, or nullopt if the slot has none or it cannot be read

Read()

std::optional<std::string> Read(std::string_view plugin) const

Reads this plugin’s data from the save: the whole of its file.

Parameter  
plugin the plugin’s name, which is also the name of its file

Returns the data, or nullopt if the save has none, because it is older than the plugin or the plugin never wrote to it

Write()

bool Write(std::string_view plugin, std::string_view data) const

Writes this plugin’s data for the save, replacing what was there.

The data goes to a temporary file that is then moved into place, so a save never holds a half-written file. Each plugin has its own file in each save, so the data needs no framing. If your format may change, store a version number in the data.

Parameter  
plugin the plugin’s name, which is also the name of its file
data any bytes: text, JSON or binary

Returns false if the file could not be written

Fields

Field Type  
character std::wstring the character’s folder name, for example “Aedan”
kind Kind = Kind::Manual  
number std::int32_t = 0