Dire
Complete cross-platform solution for data and user directories discovery.
|
#include <base.hpp>
Static Public Member Functions | |
static auto | make () -> Optional< BaseDirsBundle > |
Public Attributes | |
Path | home_dir |
Path | cache_dir |
Path | config_dir |
Path | config_local_dir |
Path | data_dir |
Path | data_local_dir |
Path | preference_dir |
Optional< Path > | executable_dir |
Optional< Path > | runtime_dir |
Optional< Path > | state_dir |
A bundle of all base directories.
These are directories used mostly internally by various programs for storing their caches, configs and other state.
executable_dir
, runtime_dir
and state_dir
don't exist on windows and macOS.
|
static |
Path dire::BaseDirsBundle::cache_dir |
A directory for program caches.
Only caches should be stored here (files safe to delete, i.e. download caches), not files that are meant to be persisted.
For configuration files: config_dir
, config_local_dir
or preference_dir
For state files: state_dir
(doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
)
For data files: data_dir
, data_local_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_CACHE_HOME or $HOME/.cache | /home/foo/.cache |
Mac | home_dir() + "/Library/Caches" | /Users/Foo/Library/Caches |
Windows | Known Folder API FOLDERID_LocalAppData | C:\Users\Foo\AppData\Local |
Path dire::BaseDirsBundle::config_dir |
A directory for program configuration files.
Only configuration files should be stored here, as users often back up this directory.
On linux and macOS this is the same as config_local_dir
.
On windows this directory can be synchronized in a domain.
For applications that are meant for power users, developers, etc., prefer this. Otherwise, prefer preference_dir
.
This matters on macOS as it stores the configuration files in $HOME/.config
instead of $HOME/Library/Application Support
.
For cache files: cache_dir
For state files: state_dir
(doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
)
For data files: data_dir
, data_local_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_CONFIG_HOME or $HOME/.config | /home/foo/.config |
Mac | home_dir() + "/.config" | /Users/Foo/.config |
Windows | Known Folder API FOLDERID_RoamingAppData | C:\Users\Foo\AppData\Roaming |
Path dire::BaseDirsBundle::config_local_dir |
A directory for program configuration files for the current user only.
Only configuration files should be stored here, as users often back up this directory.
On linux and macOS this is the same as config_dir
.
On windows this directory cannot be synchronized in the domain as opposed to config_dir
.
For applications that are meant for power users, developers, etc., prefer this. Otherwise, prefer preference_dir
.
This matters on macOS as it stores the configuration files in $HOME/.config
instead of $HOME/Library/Application Support
.
For cache files: cache_dir
For state files: state_dir
(doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
)
For data files: data_dir
, data_local_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_CONFIG_HOME or $HOME/.config | /home/foo/.config |
Mac | home_dir() + "/.config" | /Users/Foo/.config |
Windows | Known Folder API FOLDERID_LocalAppData | C:\Users\Foo\AppData\Local |
Path dire::BaseDirsBundle::data_dir |
A directory for program data files.
Used for files inherently portable across machines like icons, fonts, desktop entries and such.
On linux and macOS this is the same as data_local_dir
.
On windows this directory can be synchronized in a domain.
For state files: state_dir
(doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
)
For cache files: cache_dir
For configuration files: config_dir
, config_local_dir
or preference_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_DATA_HOME or $HOME/.local/share | /home/foo/.local/share |
Mac | home_dir() + "/Library/Application Support" | /Users/Foo/Library/Application Support |
Windows | Known Folder API FOLDERID_RoamingAppData | C:\Users\Foo\AppData\Roaming |
Path dire::BaseDirsBundle::data_local_dir |
A directory for program data files for the current user only.
Used for files inherently portable across machines like icons, fonts, desktop entries and such.
On linux and macOS this is the same as data_dir
.
On windows this directory cannot be synchronized in the domain as opposed to data_dir
.
For state files: state_dir
(doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
)
For cache files: cache_dir
For configuration files: config_dir
, config_local_dir
or preference_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_DATA_HOME or $HOME/.local/share | /home/foo/.local/share |
Mac | home_dir() + "/Library/Application Support" | /Users/Foo/Library/Application Support |
Windows | Known Folder API FOLDERID_LocalAppData | C:\Users\Foo\AppData\Local |
A user writable directory for binaries. This is not officialy supported by the XDG specification!
This directory doesn't exist on windows and macOS!
Platform | Method | Example |
---|---|---|
Linux | $XDG_BIN_HOME | /home/foo/.local/bin |
Mac | nullopt | nullopt |
Windows | nullopt | nullopt |
Path dire::BaseDirsBundle::home_dir |
Path dire::BaseDirsBundle::preference_dir |
A directory for program configuration files.
Only configuration files should be stored here, as users often back up this directory.
For applications that are meant for ordinary users prefer this.
For applications meant for developers and power users prefer config_dir
or config_local_dir
.
This matters on macOS as it stores the configuration files in $HOME/Library/Application Support
instead of $HOME/.config
.
For cache files: cache_dir
For state files: state_dir
(doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
)
For data files: data_dir
, data_local_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_CACHE_HOME or $HOME/.cache | /home/foo/.cache |
Mac | home_dir() + "/Library/Caches" | /Users/Foo/Library/Caches |
Windows | Known Folder API FOLDERID_LocalAppData | C:\Users\Foo\AppData\Local |
Used for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...)
This directory doesn't exist on windows and macOS!
Platform | Method | Example |
---|---|---|
Linux | $XDG_RUNTIME_DIR | /run/foo/1000 |
Mac | nullopt | nullopt |
Windows | nullopt | nullopt |
A directory for state files - logs, history and such.
This directory doesn't exist on windows and macOS! Use bundle.state_dir.value_or(bundle.data_local_dir)
.
For cache files: cache_dir
For configuration files: config_dir
, config_local_dir
or preference_dir
For data files: data_dir
, data_local_dir
Platform | Method | Example |
---|---|---|
Linux | $XDG_STATE_HOME or $HOME/.local/state | /home/foo/.local/state |
Mac | nullopt | nullopt |
Windows | nullopt | nullopt |