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§

  • Returns the path to the application container directory, for a given system application name.
  • Returns the path to the application container’s executable directory, for a given system application name.
  • Returns the path to the system’s application directory.
  • Returns the path to the system’s application shared components directory.
  • Returns the path to the user’s cache directory.
  • Returns the path to the user’s cache directory for a specific application.
  • Returns the path to the user’s config directory.
  • Returns the path to the user’s config directory for a specific application.
  • Returns the path to the user’s data directory.
  • Returns the path to the user’s data directory for a specific application.
  • Returns the path to the user’s local data directory.
  • Returns the path to the user’s local data directory for a specific application.
  • Returns the path to the user’s favorites directory.
  • Returns the path to the user’s favorites directory for a specific application.
  • Returns the path to the user’s log file directory.
  • Returns the path to the user’s log file directory for a specific application.
  • Returns the path to the user’s preference file directory.
  • Returns the path to the user’s preference file directory for a specific application.
  • Returns the path to the user’s template directory.
  • Returns the path to the user’s template directory for a specific application.
  • Returns the path to the application container directory, for a given user application name.
  • Returns the path to the application container’s executable directory, for a given user application name.
  • Returns the path to the user’s application directory.