Crate app_dirs [−] [src]
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
AppInfo |
Struct that holds information about your app. |
Enums
AppDataType |
Enum specifying the type of app data you want to store. |
AppDirsError |
Error type for any |
Functions
app_dir |
Creates (if necessary) and returns path to app-specific data subdirectory for provided data type and subdirectory path. |
app_root |
Creates (if necessary) and returns path to app-specific data directory for provided data type. |
data_root |
Creates (if necessary) and returns path to top-level data directory for provided data type. |
get_app_dir |
Returns (but does not create) path to app-specific data subdirectory for provided data type and subdirectory path. |
get_app_root |
Returns (but does not create) path to app-specific data directory for provided data type. |
get_data_root |
Returns (but does not create) path to top-level data directory for provided data type. |
sanitized |
Returns a cross-platform-filename-safe version of any string. |