Crate xdirs

Source
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.

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.

As is the case for dirs-next, this library provides the location of these directories by leveraging the mechanisms defined by

§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.