use std::{fs,io};
use directories::ProjectDirs;

// OS neutral path for application data
pub fn get_data_directory() -> std::path::PathBuf {
    let dirs = ProjectDirs::from("rocks","gabe","RSSCar").expect("Failed to get paths");
    match fs::create_dir(dirs.data_dir()){
        Ok(_) => {}
        Err(e) if e.kind() == io::ErrorKind::AlreadyExists => {}
        Err(_) => {println!("Unable to create data directory")}
    };
    dirs.data_dir().to_owned()
}

pub fn get_cache_directory() -> std::path::PathBuf {
    let dirs = ProjectDirs::from("rocks","gabe","RSSCar").expect("Failed to get paths");
    match fs::create_dir(dirs.cache_dir()){
        Ok(_) => {}
        Err(e) if e.kind() == io::ErrorKind::AlreadyExists => {}
        Err(_) => {println!("Error creating cache directory")}
    };
    dirs.config_dir().to_owned()

}
