checking for right filename in older savefiles
This commit is contained in:
parent
a9b9bc1de0
commit
b856a2a891
1 changed files with 28 additions and 0 deletions
|
@ -138,6 +138,7 @@ mod service_item_model {
|
||||||
// use image::{ImageBuffer, Rgba};
|
// use image::{ImageBuffer, Rgba};
|
||||||
use dirs;
|
use dirs;
|
||||||
use serde_json::{json, Deserializer, Map, Serializer, Value};
|
use serde_json::{json, Deserializer, Map, Serializer, Value};
|
||||||
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -767,6 +768,33 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// older save files use servicelist.json instead of serviceitems.json
|
||||||
|
// Let's check to see if that's the case and change it's name in the
|
||||||
|
// temp dir.
|
||||||
|
for mut file in fs::read_dir(datadir.clone())
|
||||||
|
.unwrap()
|
||||||
|
.filter(|f| {
|
||||||
|
f.as_ref()
|
||||||
|
.map(|e| {
|
||||||
|
String::from(
|
||||||
|
e.file_name().to_str().unwrap(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.unwrap_or(String::from(""))
|
||||||
|
== "servicelist.json"
|
||||||
|
})
|
||||||
|
{
|
||||||
|
let mut service_path = datadir.clone();
|
||||||
|
service_path.push("serviceitems.json");
|
||||||
|
match fs::rename(
|
||||||
|
file.unwrap().path(),
|
||||||
|
service_path,
|
||||||
|
) {
|
||||||
|
Ok(i) => println!("We did it captain"),
|
||||||
|
Err(e) => println!("error: {:?}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut service_path = datadir.clone();
|
let mut service_path = datadir.clone();
|
||||||
service_path.push("serviceitems.json");
|
service_path.push("serviceitems.json");
|
||||||
// let mut service_list =
|
// let mut service_list =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue