Skip to main content

Module storage

Module storage 

Source
Expand description

Where an app keeps its own files: its data, cache and configuration directories, each a folder named after the app id in the place its platform sets aside for that kind of file (docs/fs.md “Where files live”). Every Day crate that stores files resolves them here, so an app’s database, documents, caches, settings file and remembered window frames sit together and apart from every other app’s.

These only resolve paths; nothing is created until something is written. Each is None where the platform has no such directory: the web, or an Android or HarmonyOS process whose host passed none.

Functions§

app_id
The app’s id, [app] id from Day.toml: DAY_APP_ID from day launch, else the value day build baked in, else the executable’s name (a test binary or a bare cargo run). Made safe as a single folder name.
cache_dir
The app’s cache directory, for what it can fetch or compute again: the system may clear it, and backups skip it. Caches on Apple platforms, %LOCALAPPDATA%\<id>\cache on Windows, $XDG_CACHE_HOME on Linux, the app’s cache directory on Android and HarmonyOS. DAY_CACHE_DIR replaces it; with only DAY_DATA_DIR set it is that directory’s cache.
config_dir
The app’s configuration directory, for small settings files: Application Support on Apple platforms (whose preferences proper are the user defaults), the roaming %APPDATA% on Windows, $XDG_CONFIG_HOME on Linux. With DAY_DATA_DIR set (as the Android and HarmonyOS hosts do) it is that directory’s config.
data_dir
The app’s data directory, for what it cannot recreate: databases, documents, downloads the user kept. Application Support on Apple platforms (inside the container when sandboxed), %LOCALAPPDATA% on Windows, $XDG_DATA_HOME on Linux, the app’s files directory on Android and HarmonyOS. DAY_DATA_DIR replaces it.
data_dir_for
data_dir for the app app_id rather than this process’s own: a host that keeps a folder per hosted app (a day-lite superapp, a crash reporter’s store), or a tool finding where an app it launched writes. On Android and HarmonyOS, where the host’s directory is already the one app’s, the id changes nothing.