1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
extern crate xdg_basedir;
use std::error::Error;
use std::fs::create_dir_all;
use std::path::PathBuf;
pub fn dir_config_create(name: &str) -> Result<PathBuf, Box<Error>> {
let path = try!(dir_config(name));
try!(create_dir_all(path.as_path()));
Ok(path)
}
pub fn dir_config(name: &str) -> Result<PathBuf, Box<Error>> {
let mut path = try!(xdg_basedir::get_config_home());
path.push(name);
Ok(path)
}
pub fn dir_data_create(name: &str) -> Result<PathBuf, Box<Error>> {
let path = try!(dir_data(name));
try!(create_dir_all(path.as_path()));
Ok(path)
}
pub fn dir_data(name: &str) -> Result<PathBuf, Box<Error>> {
let mut path = try!(xdg_basedir::get_data_home());
path.push(name);
Ok(path)
}