Skip to main content

Module storage

Module storage 

Source
Expand description

Platform Storage backends (ticket 0207, game ADR-0009): files in the OS data directory on native, localStorage on web.

Structs§

FileStorage
A Storage backed by one file per key, under the OS’s per-app data directory (data_dir).

Functions§

data_dir
The OS’s per-app data directory for the game whose storage is called name: that folder in %APPDATA% on Windows, in ~/Library/Application Support on macOS, in $XDG_DATA_HOME (or ~/.local/share) elsewhere on Unix. None if the relevant environment variable isn’t set.
platform
The storage backend for this platform, for the game whose storage is called name (AppConfig::storage_name). Native falls back to an in-memory store (nothing persists) if the OS has no usable data directory (the relevant environment variable is unset, which only happens on unsupported or misconfigured systems); it logs an error when that happens.
smoke_check
A startup check, which the backend runs in debug builds as it hands the game its storage: writes and reads back a throwaway key and logs the result, then removes it.
web_prefix
The prefix of every key the web build keeps in localStorage for the game whose storage is called name: name/.