seting up conf
This commit is contained in:
20
src/conf.rs
20
src/conf.rs
@@ -2,19 +2,27 @@
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
mod defaltConf;
|
||||
|
||||
|
||||
pub fn check(fileLocation: str){
|
||||
|
||||
pub fn checkAndCreateIfNeeded(fileLocation: str) -> File{
|
||||
let confPath = Path::new(fileLocation);
|
||||
let confDisplay = confPath.display();
|
||||
let mut confFile = match File::open(&confPath){
|
||||
Err(why) =>
|
||||
|
||||
}
|
||||
Err(why) => createConf(fileLocation),
|
||||
Ok(conf) => confFile,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
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
11
src/defaultConf.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
static DEFAULTCONF &str = "
|
||||
|
||||
|
||||
|
||||
|
||||
"
|
||||
|
||||
|
||||
pub fn getDefaultConf() -> str{
|
||||
return DEFAULTCONF;
|
||||
}
|
||||
Reference in New Issue
Block a user