Debian Codegraph @

src/imp/platform/unix.rs

raw symbols SCIP
1 extern crate xdg;
2 use self::xdg::BaseDirectories as Xdg;
3 use crate::common::*;
4 use crate::AppDataType::*;
5 use std::path::PathBuf;
6
7 pub const USE_AUTHOR: bool = false;
8
9 pub fn get_app_dir(t: AppDataType) -> Result<PathBuf, AppDirsError> {
10 Xdg::new()
11 .ok()
12 .as_ref()
13 .and_then(|x| match t {
14 UserConfig => Some(x.get_config_home()),
15 UserData => Some(x.get_data_home()),
16 UserCache => Some(x.get_cache_home()),
17 SharedData => x.get_data_dirs().into_iter().next(),
18 SharedConfig => x.get_config_dirs().into_iter().next(),
19 })
20 .ok_or(AppDirsError::NotSupported)
21 }