Base Directory
See XDG Base Directory Specification
Regardless of the platform, check the environment variable XDG_XYZ_ABC,
If it exists, use the folder defined by the environment variable,
Otherwise, use the platform’s default folder
All paths set in these environment variables must be absolute. If an implementation encounters a relative path in any of these variables it should consider the path invalid and ignore it.
Variables that may be used:
{USER}: Username (Unix-like: environment variableUSER,Windows: environment variableUSER_NAME){UID}: User ID (Only inUnix-like){APP_NAME}: Application Name{APPDATA}: environment variableAPPDATA(Only inWindows){LOCALAPPDATA}: environment variableLOCALAPPDATA(Only inWindows)
User-specific Data
XDG: XDG_DATA_HOME:
Unix-like:~/.local/share/{APP_NAME}Windows:{APPDATA}/{APP_NAME}/dataMacOS:~/Library/Application Support/
User-specific Configuration
XDG: XDG_CONFIG_HOME
Unix-like:~/.config/{APP_NAME}Windows:{APPDATA}/{APP_NAME}/configMacOS:~/Library/Preferences/
User-specific State Data
XDG: XDG_STATE_HOME:
Unix-like:~/.local/state/{APP_NAME}Windows:{LOCALAPPDATA}/{APP_NAME}/stateMacOS:~/Library/Application Support/
User-specific Cached Data
XDG: XDG_CACHE_HOME:
Unix-like:~/.cache/{APP_NAME}Windows:{LOCALAPPDATA}/{APP_NAME}/cacheMacOS:~/Library/Caches/
User-specific Runtime Files
XDG: XDG_RUNTIME_DIR:
Linux:/run/user/{UID}Windows:%TEMP%MacOS:$TMPDIRUnix-like:/var/run/user/{UID}
System Runtime Files
Similar to this
rust:std::env::temp_dir()
Linux:/tmpAndroid: Decided by the system
Windows:GetTempPath2/GetTempPathMacOS:confstr(_CS_DARWIN_USER_TEMP_DIR, ...)Unix-like:/tmp