2017-10-19 14:04:58 +00:00
|
|
|
use std;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
pub fn get_app_config_dir_create() -> Result<PathBuf, String> {
|
|
|
|
let config_dir = get_app_config_dir()?;
|
|
|
|
|
2017-10-24 15:03:34 +00:00
|
|
|
std::fs::create_dir_all(&config_dir).map_err(
|
|
|
|
|e| format!("{}", e),
|
|
|
|
)?;
|
2017-10-19 14:04:58 +00:00
|
|
|
|
|
|
|
Ok(config_dir)
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:03:34 +00:00
|
|
|
pub fn get_app_config_dir() -> Result<PathBuf, String> {
|
2017-10-19 14:04:58 +00:00
|
|
|
let mut config_dir = get_xdg_config_dir()?;
|
|
|
|
|
|
|
|
config_dir.push("nvim-gtk");
|
|
|
|
|
|
|
|
Ok(config_dir)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_xdg_config_dir() -> Result<PathBuf, String> {
|
|
|
|
if let Ok(config_path) = std::env::var("XDG_CONFIG_HOME") {
|
|
|
|
return Ok(PathBuf::from(config_path));
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:03:34 +00:00
|
|
|
let mut home_dir = std::env::home_dir().ok_or(
|
|
|
|
"Impossible to get your home dir!",
|
|
|
|
)?;
|
2017-10-19 14:04:58 +00:00
|
|
|
home_dir.push(".config");
|
|
|
|
Ok(home_dir)
|
|
|
|
}
|