refactor: compact

This commit is contained in:
🪞👃🪞 2024-06-07 16:51:30 +03:00
parent abee6cc2c8
commit 60627ac3e5
43 changed files with 923 additions and 780 deletions

23
src/config.rs Normal file
View file

@ -0,0 +1,23 @@
use crate::prelude::*;
const CONFIG_FILE_NAME: &'static str = "dawdle.toml";
pub fn create_dirs (xdg: &microxdg::XdgApp) -> Result<(), Box<dyn Error>> {
use std::{path::Path,fs::{File,create_dir_all}};
let config_dir = xdg.app_config()?;
if !Path::new(&config_dir).exists() {
println!("Creating {config_dir:?}");
create_dir_all(&config_dir)?;
}
let config_path = config_dir.join(CONFIG_FILE_NAME);
if !Path::new(&config_path).exists() {
println!("Creating {config_path:?}");
File::create_new(&config_path)?;
}
let data_dir = xdg.app_data()?;
if !Path::new(&data_dir).exists() {
println!("Creating {data_dir:?}");
create_dir_all(&data_dir)?;
}
Ok(())
}