| Crates.io | xdgdir |
| lib.rs | xdgdir |
| version | 0.8.0 |
| created_at | 2025-09-15 13:41:31.802132+00 |
| updated_at | 2025-09-15 13:41:31.802132+00 |
| description | Resolves paths according to the XDG Base Directory Specification |
| homepage | https://github.com/pyk/xdgdir |
| repository | https://github.com/pyk/xdgdir |
| max_upload_size | |
| id | 1839973 |
| size | 27,228 |
xdgdir helps you to resolves paths according to the
XDG Base Directory Specification.
Add xdgdir to your project's dependencies:
cargo add xdgdir
To get the set of directories for your specific application, use
BaseDir::new().
use xdgdir::BaseDir;
fn main() {
let dirs = BaseDir::new("my-app").unwrap();
println!("Config file should be in: {}", dirs.config.display());
// -> /home/user/.config/my-app
println!("Data files should be in: {}", dirs.data.display());
// -> /home/user/.local/share/my-app
}
To get the raw, non-application-specific base directories, use
BaseDir::global().
use xdgdir::BaseDir;
fn main() {
let global_dirs = BaseDir::global().unwrap();
println!("Default user config dir: {}", global_dirs.config.display());
// -> /home/user/.config
println!("User executables dir: {}", global_dirs.bin.display());
// -> /home/user/.local/bin
}
This project is licensed under the MIT License.