| 1 |
use crate::common::*; |
| 2 |
use crate::AppDataType::*; |
| 3 |
use std::path::{Component, Path, PathBuf}; |
| 4 |
|
| 5 |
pub const USE_AUTHOR: bool = false; |
| 6 |
|
| 7 |
#[allow(deprecated)] |
| 8 |
pub fn get_app_dir(t: AppDataType) -> Result<PathBuf, AppDirsError> { |
| 9 |
let dir_base: Result<PathBuf, AppDirsError> = if t.is_shared() { |
| 10 |
Ok(Path::new(&Component::RootDir).into()) |
| 11 |
} else { |
| 12 |
std::env::home_dir().ok_or_else(|| AppDirsError::NotSupported) |
| 13 |
}; |
| 14 |
dir_base.map(|mut path| { |
| 15 |
match t { |
| 16 |
UserConfig | UserData | SharedConfig | SharedData => { |
| 17 |
path.push("Library"); |
| 18 |
path.push("Application Support"); |
| 19 |
}, |
| 20 |
UserCache => { |
| 21 |
path.push("Library"); |
| 22 |
path.push("Caches"); |
| 23 |
}, |
| 24 |
}; |
| 25 |
path |
| 26 |
}) |
| 27 |
} |