Fixed config and cache files locations
This commit is contained in:
parent
9dc91f4677
commit
431852f1e0
9 changed files with 112 additions and 17 deletions
28
src/utils.rs
28
src/utils.rs
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue