A small Rust library for obtaining platform dependant directory paths for application and user directories.
Note that the directory paths are not guaranteed to exist.
Allows for specifying if an application is CLI or GUI based, since on macOS, CLI applications are expected to conform to the XDG spec, while GUI applications are expected to conform to the Standard Directories guidelines.
The API is still being flushed out, so feel free to PR any breaking changes or additions.
```rust use platform_dirs::{AppDirs, AppUI, UserDirs};
if let Some(appdirs) = AppDirs::new(Some("program-name"), AppUI::Graphical) appdirs.config_dir; // Linux: /home/alice/.config/program-name // Windows: C:\Users\Alice\AppData\Roaming\program-name // macOS: /Users/Alice/Library/Application Support/program-name }
if let Some(appdirs) = AppDirs::new::
if let Some(userdirs) = UserDirs::new() { userdirs.music_dir; // Linux: /home/alice/Music // Windows: C:\Users\Alice\Music // macOS: /Users/Alice/Music } ```
Add the following to Cargo.toml:
toml
[dependencies]
platform-dirs = "0.1.0"