#application #data #storage #location #directory

app_dirs

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

10 releases (6 stable)

1.2.1 Mar 29, 2018
1.1.1 Oct 29, 2016
0.1.0 Oct 20, 2016
0.0.2 Mar 11, 2016

#5 in Database interfaces

Download history 496/week @ 2018-09-14 629/week @ 2018-09-21 569/week @ 2018-09-28 614/week @ 2018-10-05 615/week @ 2018-10-12 740/week @ 2018-10-19 545/week @ 2018-10-26 917/week @ 2018-11-02 855/week @ 2018-11-09 929/week @ 2018-11-16 2336/week @ 2018-11-23 1541/week @ 2018-11-30 1284/week @ 2018-12-07

6,458 downloads per month
Used in 37 crates (30 directly)

MIT license

20KB
336 lines

app_dirs

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

crates.io: app_dirs Linux & OS X build status Windows build status

Documentation & examples

https://docs.rs/app_dirs

Installation

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

app_dirs = "^1.2.1"

lib.rs:

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

Usage

extern crate app_dirs;
use app_dirs::*;

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

~156KB