Fixed config and cache files locations

This commit is contained in:
Antoine Gersant 2016-11-21 00:13:55 -08:00
parent 9dc91f4677
commit 431852f1e0
9 changed files with 112 additions and 17 deletions

View file

@ -1,4 +1,30 @@
use std::path::Path;
use app_dirs::{AppDataType, data_root};
use std::path::{Path, PathBuf};
use std::fs;
use error::PError;
pub fn get_config_root() -> Result<PathBuf, PError> {
if let Ok(mut root) = data_root(AppDataType::UserConfig){
root.push("Polaris");
return match fs::create_dir_all(&root) {
Ok(()) => Ok(root),
Err(_) => Err(PError::CacheDirectoryError),
}
}
Err(PError::ConfigDirectoryError)
}
pub fn get_cache_root() -> Result<PathBuf, PError> {
if let Ok(mut root) = data_root(AppDataType::UserCache){
root.push("Polaris");
return match fs::create_dir_all(&root) {
Ok(()) => Ok(root),
Err(_) => Err(PError::CacheDirectoryError),
}
}
Err(PError::CacheDirectoryError)
}
pub enum AudioFormat {
FLAC,