Fray Engine
Loading...
Searching...
No Matches
fray::state Namespace Reference

Classes

class  StateManager
 Owns a SQLite connection and a typed key/value state table. Database operations serialize on a recursive mutex; the attached FileManager is borrowed, not owned. More...

Functions

F_err readApplicationLocation (const std::filesystem::path &directory, std::filesystem::path &result)
 Reads the selected application database path, if one has been recorded.
F_err writeApplicationFile (const std::filesystem::path &directory, const std::string &filename, const std::string &value, bool replaceExisting=true)
 Atomically replaces a named application-owned file.
F_err writeApplicationLocation (const std::filesystem::path &directory, const std::filesystem::path &database)
 Atomically records the selected application database path.

Variables

constexpr const char * applicationLocationFile = "Fray.application-database"
 Name of the Engine-adjacent file identifying the selected application database.

Function Documentation

◆ readApplicationLocation()

F_err fray::state::readApplicationLocation ( const std::filesystem::path & directory,
std::filesystem::path & result )
inline

Reads the selected application database path, if one has been recorded.

Parameters
directoryEngine directory containing the location file.
resultReceives an absolute path, or an empty path when no choice is saved.
Returns
NONE on success, otherwise FAILED_OPEN_STORE.

Definition at line 40 of file application_state_location.hpp.

◆ writeApplicationFile()

F_err fray::state::writeApplicationFile ( const std::filesystem::path & directory,
const std::string & filename,
const std::string & value,
bool replaceExisting = true )
inline

Atomically replaces a named application-owned file.

Parameters
directoryExisting directory containing the file.
filenameSimple file name within the directory.
valueComplete file contents.
replaceExistingReplace an existing file; otherwise leave it untouched.
Returns
NONE on success, otherwise FAILED_SAVE_STATE.

Definition at line 91 of file application_state_location.hpp.

◆ writeApplicationLocation()

F_err fray::state::writeApplicationLocation ( const std::filesystem::path & directory,
const std::filesystem::path & database )
inline

Atomically records the selected application database path.

Parameters
directoryEngine directory containing the location file.
databaseAbsolute application database path.
Returns
NONE on success, otherwise FAILED_SAVE_STATE.

Definition at line 204 of file application_state_location.hpp.

Variable Documentation

◆ applicationLocationFile

const char* fray::state::applicationLocationFile = "Fray.application-database"
inlineconstexpr

Name of the Engine-adjacent file identifying the selected application database.

Definition at line 32 of file application_state_location.hpp.