Expand description
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")
}
Structs
Struct that holds information about your app.
Enums
Enum specifying the type of app data you want to store.
Error type for any app_dirs
operation.
Functions
Creates (if necessary) and returns path to app-specific data subdirectory for provided data type and subdirectory path.
Creates (if necessary) and returns path to app-specific data directory for provided data type.
Creates (if necessary) and returns path to top-level data directory for provided data type.
Returns (but does not create) path to app-specific data subdirectory for provided data type and subdirectory path.
Returns (but does not create) path to app-specific data directory for provided data type.
Returns (but does not create) path to top-level data directory for provided data type.
Returns a cross-platform-filename-safe version of any string.