### Get Project, Base, and User Directories Source: https://github.com/dirs/directories-rs/blob/main/README.md This example demonstrates how to obtain configuration, cache, and data directories for a specific project, as well as general base and user directories. It shows how to access config_dir, executable_dir, and audio_dir. Note that some directories might not be available on all platforms. ```rust extern crate directories; use directories::{BaseDirs, UserDirs, ProjectDirs}; if let Some(proj_dirs) = ProjectDirs::from("com", "Foo Corp", "Bar App") { proj_dirs.config_dir(); // Lin: /home/alice/.config/barapp // Win: C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config // Mac: /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App } if let Some(base_dirs) = BaseDirs::new() { base_dirs.executable_dir(); // Lin: Some(/home/alice/.local/bin) // Win: None // Mac: None } if let Some(user_dirs) = UserDirs::new() { user_dirs.audio_dir(); // Lin: /home/alice/Music // Win: C:\Users\Alice\Music // Mac: /Users/Alice/Music } ``` -------------------------------- ### Cross-Compilation Build Targets Source: https://github.com/dirs/directories-rs/blob/main/README.md Build the library on various platforms for cross-compilation. Ensure necessary toolchains are installed with rustup. ```bash cargo build --target=x86_64-unknown-linux-gnu cargo build --target=x86_64-pc-windows-gnu cargo build --target=x86_64-apple-darwin cargo build --target=x86_64-unknown-redox ``` -------------------------------- ### Create ProjectDirs Instance Source: https://github.com/dirs/directories-rs/blob/main/README.md Instantiate ProjectDirs by providing a qualifier, organization, and application name. The resulting path varies by operating system. ```rust ProjectDirs::from("org", /*qualifier*/ "Baz Corp", /*organization*/ "Foo Bar-App" /*application*/) ``` -------------------------------- ### Create ProjectDirs from Path Source: https://github.com/dirs/directories-rs/blob/main/README.md Create a ProjectDirs instance directly from a PathBuf. This method is discouraged as it may not adhere to operating system standards. ```rust ProjectDirs::from_path(path: &Path) ``` -------------------------------- ### ProjectDirs Path Values Source: https://github.com/dirs/directories-rs/blob/main/README.md Illustrates the computed path values for cache, config, and data directories across different operating systems based on the provided project details. ```text Value on Linux | Value on Windows | Value on macOS | -------------- | ------------------------ | ---------------------------- | "foobar-app" | "Baz Corp/Foo Bar-App" | "org.Baz-Corp.Foo-Bar-App" ``` -------------------------------- ### Add directories to Cargo.toml Source: https://github.com/dirs/directories-rs/blob/main/README.md Add the 'directories' library as a dependency to your project by including this line in your Cargo.toml file. ```toml directories = "6.0" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.