seting up conf

This commit is contained in:
cyclic
2026-01-13 12:19:47 -06:00
parent 8ff80750cb
commit 5cd23991b3
2 changed files with 25 additions and 6 deletions

View File

@@ -2,19 +2,27 @@
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
use std::path::Path; use std::path::Path;
mod defaltConf;
pub fn check(fileLocation: str){
pub fn checkAndCreateIfNeeded(fileLocation: str) -> File{
let confPath = Path::new(fileLocation); let confPath = Path::new(fileLocation);
let confDisplay = confPath.display(); let confDisplay = confPath.display();
let mut confFile = match File::open(&confPath){ let mut confFile = match File::open(&confPath){
Err(why) => Err(why) => createConf(fileLocation),
Ok(conf) => confFile,
} };
} }
fn createConf(fileLocation: str){ fn createConf(fileLocation: str){
let confPath = Path::new(fileLocation);
let confDisplay = confPath.display();
let mut confFile = match File::create(&path){
Err(why) => panic!("couldn't create {}: {}", display, why),
Ok(file) => file,
};
match confFile.write_all(defaltConf::getDefaultConf());
return checkAndCreateIfNeeded();
} }

11
src/defaultConf.rs Normal file
View File

@@ -0,0 +1,11 @@
static DEFAULTCONF &str = "
"
pub fn getDefaultConf() -> str{
return DEFAULTCONF;
}