#application #data #storage #location #directory

app_dirs2

Put your app’s data in the right place on every platform. Community-maintained project.

8 stable releases

✓ Uses Rust 2018 edition

new 2.2.1 Jul 9, 2020
2.1.0 Jul 8, 2020
2.0.4 Sep 20, 2019
2.0.3 Mar 27, 2018

#50 in Filesystem

Download history 401/week @ 2020-03-23 329/week @ 2020-03-30 125/week @ 2020-04-06 358/week @ 2020-04-13 366/week @ 2020-04-20 426/week @ 2020-04-27 387/week @ 2020-05-04 371/week @ 2020-05-11 171/week @ 2020-05-18 114/week @ 2020-05-25 324/week @ 2020-06-01 378/week @ 2020-06-08 229/week @ 2020-06-15 223/week @ 2020-06-22 140/week @ 2020-06-29 170/week @ 2020-07-06

1,202 downloads per month
Used in 10 crates (5 directly)

MIT license

25KB
410 lines

app_dirs

Put your app's data in the right place on every platform

crates.io:app_dirs2

This is the up-to-date version of app_dirs

The original app_dirs crate is unmaintained and has seriously outdated dependencies. This is an fork that keeps the crate working and up-to-date.

This is a community-maintained project, so if you find a bug or the crate is missing support for your platform, please help out.

There are no major changes planned. If you're looking for a crate with more features, check out the directories crate.

Documentation & examples

https://docs.rs/app_dirs2

Installation

Add the following to your Cargo.toml under [dependencies]:

app_dirs2 = "2"

lib.rs:

Put your app's data in the right place on every platform

Usage

extern crate app_dirs2;
use app_dirs2::*;

const APP_INFO: AppInfo = AppInfo{name: "CoolApp", author: "SuperDev"};

fn main () {
    // Where should I store my app's per-user configuration data?
    println!("{:?}", get_app_root(AppDataType::UserConfig, &APP_INFO));
    // Windows: "%APPDATA%\SuperDev\CoolApp"
    //   (e.g.: "C:\Users\Rusty\AppData\Roaming\SuperDev\CoolApp")
    //   macOS: "$HOME/Library/Application Support/CoolApp"
    //   (e.g.: "/Users/Rusty/Library/Application Support/CoolApp")
    //    *nix: "$HOME/.config/CoolApp" (or "$XDG_CONFIG_HOME/CoolApp", if defined)
    //   (e.g.: "/home/rusty/.config/CoolApp")

    // How about nested cache data?
    println!("{:?}", get_app_dir(AppDataType::UserCache, &APP_INFO, "cache/images"));
    // Windows: "%LOCALAPPDATA%\SuperDev\CoolApp\cache\images"
    //   (e.g.: "C:\Users\Rusty\AppData\Local\SuperDev\CoolApp\cache\images")
    //   macOS: "$HOME/Library/Caches/CoolApp/cache/images"
    //   (e.g.: "/Users/Rusty/Library/Caches/CoolApp/cache/images")
    //    *nix: "$HOME/.cache/CoolApp/cache/images"
    //          (or "$XDG_CACHE_HOME/CoolApp/cache/images", if defined)
    //   (e.g.: "/home/rusty/.cache/CoolApp/cache/images")

    // Remove "get_" prefix to recursively create nonexistent directories:
    // app_root(AppDataType::UserConfig, &APP_INFO)
    // app_dir(AppDataType::UserCache, &APP_INFO, "cache/images")
}

Dependencies

~0–710KB
~18K SLoC