Crates.io | xdirs |
lib.rs | xdirs |
version | 0.1.1 |
source | src |
created_at | 2021-03-02 03:12:59.376429 |
updated_at | 2021-03-02 17:15:46.303429 |
description | Additional functions for application paths, based on the dirs-next crate. |
homepage | |
repository | https://github.com/johnstonskj/rust-xdirs.git |
max_upload_size | |
id | 362435 |
size | 49,834 |
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, and so these additional functions will
ensure the correct construction of the application-specific path.
This is an alternative to the directories-next and maintains a closer interface to dirs-next.
Generic Form | dirs | Application-Specific Form |
---|---|---|
cache_dir |
Yes | cache_dir_for |
config_dir |
Yes | config_dir_for |
data_dir |
Yes | data_dir_for |
data_local_dir |
Yes | data_local_dir_for |
favorites_dir |
No | favorites_dir_for |
log_dir |
No | log_dir_for |
preference_dir |
No | preference_dir_for |
template_dir |
Yes | template_dir_for |
The column dirs denotes whether the generic form is present in the dirs or dirs-next crate.
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);
The following may be used to determine the location for installed applications.
application_dir
application_shared_dir
user_application_dir
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.
Version 0.1.1
Version 0.1.0