mirror of
https://github.com/alterware/alterware-launcher.git
synced 2025-12-04 15:27:48 +00:00
misc
This commit is contained in:
@@ -13,17 +13,18 @@ pub fn load(config_path: PathBuf) -> Config {
|
||||
}
|
||||
|
||||
pub fn save(config_path: PathBuf, config: Config) {
|
||||
match fs::write(config_path.clone(), serde_json::to_string_pretty(&config).unwrap()) {
|
||||
match fs::write(
|
||||
config_path.clone(),
|
||||
serde_json::to_string_pretty(&config).unwrap(),
|
||||
) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
match e.kind() {
|
||||
std::io::ErrorKind::NotFound => {
|
||||
fs::create_dir_all(config_path.parent().unwrap()).unwrap();
|
||||
return save(config_path, config);
|
||||
}
|
||||
_ => println!("Could not save config file, got:\n{}\n", e),
|
||||
Err(e) => match e.kind() {
|
||||
std::io::ErrorKind::NotFound => {
|
||||
fs::create_dir_all(config_path.parent().unwrap()).unwrap();
|
||||
save(config_path, config);
|
||||
}
|
||||
}
|
||||
_ => println!("Could not save config file, got:\n{}\n", e),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user