directories
Functions
pub fn cache_dir() -> Result(String, Nil)
Returns the path to the user-specific cache directory
On Windows, it’ll return the value of %APPDATA%
if it exists
On MacOS, it’ll return value of $HOME/Library/Caches
if it exists
On Linux and FreeBSD, it’ll check $XDG_CACHE_HOME
and $HOME/.cache
, returning the first one that is a valid directory
pub fn config_dir() -> Result(String, Nil)
Returns the path to the user-specific config directory. This directory may be synced across computers
On Windows, it’ll return the value of %APPDATA%
if it exists
On MacOS, it’ll return the value of $HOME/Library/Application Support
if it exists
On Linux and FreeBSD, it’ll check $XDG_CONFIG_HOME
and $HOME/.config
, returning the first one that is a valid directory
pub fn config_local_dir() -> Result(String, Nil)
Returns the path to the user-specific local config directory. Similar to config_dir
, except Windows won’t sync it when connected to a domain with a roaming profile
On Windows, it’ll return the value of %LOCALAPPDATA%
if it exists
On MacOS, it’ll return the value of $HOME/Library/Application Support
if it exists
On Linux and FreeBSD, it’ll check $XDG_CONFIG_HOME
and $HOME/.config
, returning the first one that is a valid directory
pub fn data_dir() -> Result(String, Nil)
Returns the path to the user-specific data directory. This directory may be synced across computers
On Windows, it’ll return the value of %APPDATA%
if it exists
On MacOS, it’ll return the value of $HOME/Library/Application Support
if it exists
On Linux and FreeBSD, it’ll check `$XDG_DATA_HOME``and $HOME/.local/share, returning the first one that is a valid directory
pub fn data_local_dir() -> Result(String, Nil)
Returns the path to the user-specific data directory. Similar to data_dir
, except Windows won’t sync it when connected to a domain with a roaming profile
On Windows, it’ll return the value of %LOCALAPPDATA%
if it exists
On MacOS, it’ll return the value of $HOME/Library/Application Support
if it exists
On Linux and FreeBSD, it’ll check DG_DATA_HOME $H`````ocal/share, r
g``` the first one that is a valid directory
pub fn executable_dir() -> Result(String, Nil)
Returns the path to which user-specific executable files may be written.
On Linux and FreeBSD, it’ll check $XDG_BIN_HOME, $HOME/.local/bin, $XDG_DATA_HOME/../bin and return the first one that is a valid directory
On all other platforms, it’ll always return Error(Nil)
pub fn home_dir() -> Result(String, Nil)
Returns the path to the user’s home directory
It’ll check %UserProfile%
and %Profile%
on windows, returning first one that is a valid directory
On MacOS, Linux, and FreeBSD, it’ll return the value of $HOME
if it exists
pub fn preference_dir() -> Result(String, Nil)
Returns the path to the user-specific preferences directory. This directory may be synced across computers
On Windows, it’ll return the value of %APPDATA%
if it exists
On MacOS, it’ll return the value of $HOME/Library/Preferences
if it exists
On Linux and FreeBSD, it’ll check $XDG_CONFIG_HOME and $HOME/.config, returning the first one that is a valid directory
pub fn runtime_dir() -> Result(String, Nil)
Returns the path to which user-specific runtime files and other file objects may be placed.
On Linux and FreeBSD, it’ll check $XDG_RUNTIME_DIR if it is a valid directory
On all other platforms, it’ll always return Error(Nil)
pub fn state_dir() -> Result(String, Nil)
Returns the path to which user-specific state may be stored.
The state directory contains data that should be retained between sessions (unlike the runtime directory), but may not be important/portable enough to be synchronized across machines (unlike the config/preferences/data directories).
On Linux and FreeBSD, it’ll check $XDG_STATE_HOME and $HOME/.local/state, returning the first one that is a valid directory
On all other platforms, it’ll always return Error(Nil)
pub fn tmp_dir() -> Result(String, Nil)
Returns the path to a temporary directory
It’ll first check %TMPDIR%
, %TEMP%
, %TMP%
, and return the first one that is a valid directory
If that fails, It’ll check C:\TEMP
, C:\TMP
, \TEMP
, \TMP
on windows.
On MacOS, Linux, and FreeBSD, it’ll check /tmp
, /var/tmp
, /usr/tmp
,