Expand description
Additional functions for application paths, based on dirs-next.
This crate extends the set of paths used by an application to store data and configuration. It
compliments functions such as cache_dir
, config_dir
, and data_dir
with versions with a
suffix _for
that take an application name. It is not the case that for all of such paths it
is safe to append an application name to the generic path, so these additional functions will
ensure the correct construction of the application-specific path.
Generic Form | Application-Specific Form |
---|---|
cache_dir | cache_dir_for |
config_dir | config_dir_for |
data_dir | data_dir_for |
data_local_dir | data_local_dir_for |
favorites_dir | favorites_dir_for |
log_dir | log_dir_for |
preference_dir | preference_dir_for |
cache_dir | cache_dir_for |
template_dir | template_dir_for |
Additionally the following may be used to determine the location for installed applications.
Finally, for systems that support a notion of an application container or bundle, the following will provide the location to these directories. Currently these only provide values on macOS.
app_container_dir_for
app_container_executable_dir_for
user_app_container_dir_for
user_app_container_executable_dir_for
As is the case for dirs-next, this library provides the location of these directories by leveraging the mechanisms defined by
- the XDG base directory and the XDG user directory specifications on Linux,
- the Known Folder system on Windows, and
- the Standard Directories on macOS.
§Example
use xdirs::{application_dir, config_dir_for, log_dir_for};
const APP_NAME: &str = env!("CARGO_PKG_NAME");
let where_is_my_app_installed = application_dir();
let where_do_i_read_my_config = config_dir_for(APP_NAME);
let where_do_i_write_log_files = log_dir_for(APP_NAME);
Functions§
- app_
container_ dir_ for - Returns the path to the application container directory, for a given system application name.
- app_
container_ executable_ dir_ for - Returns the path to the application container’s executable directory, for a given system application name.
- application_
dir - Returns the path to the system’s application directory.
- application_
shared_ dir - Returns the path to the system’s application shared components directory.
- cache_
dir - Returns the path to the user’s cache directory.
- cache_
dir_ for - Returns the path to the user’s cache directory for a specific application.
- config_
dir - Returns the path to the user’s config directory.
- config_
dir_ for - Returns the path to the user’s config directory for a specific application.
- data_
dir - Returns the path to the user’s data directory.
- data_
dir_ for - Returns the path to the user’s data directory for a specific application.
- data_
local_ dir - Returns the path to the user’s local data directory.
- data_
local_ dir_ for - Returns the path to the user’s local data directory for a specific application.
- favorites_
dir - Returns the path to the user’s favorites directory.
- favorites_
dir_ for - Returns the path to the user’s favorites directory for a specific application.
- log_dir
- Returns the path to the user’s log file directory.
- log_
dir_ for - Returns the path to the user’s log file directory for a specific application.
- preference_
dir - Returns the path to the user’s preference file directory.
- preference_
dir_ for - Returns the path to the user’s preference file directory for a specific application.
- template_
dir - Returns the path to the user’s template directory.
- template_
dir_ for - Returns the path to the user’s template directory for a specific application.
- user_
app_ container_ dir_ for - Returns the path to the application container directory, for a given user application name.
- user_
app_ container_ executable_ dir_ for - Returns the path to the application container’s executable directory, for a given user application name.
- user_
application_ dir - Returns the path to the user’s application directory.