mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
refactor: compact
This commit is contained in:
parent
abee6cc2c8
commit
60627ac3e5
43 changed files with 923 additions and 780 deletions
23
src/config.rs
Normal file
23
src/config.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
const CONFIG_FILE_NAME: &'static str = "dawdle.toml";
|
||||
|
||||
pub fn create_dirs (xdg: µxdg::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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue