merge config from previous versions

This commit is contained in:
Salem Yaslem 2021-02-08 04:28:48 +03:00
parent 59d48a1070
commit c1ec746087
2 changed files with 17 additions and 0 deletions

View File

@ -23,6 +23,22 @@ pub fn initialize() -> PathBuf {
config_path
}
pub fn merge_previous_version() -> Option<PathBuf> {
let config_path: PathBuf = Path::new(&get_user_data_dir().unwrap())
.join("blue-recorder")
.join("config.ini");
// return none if config.ini not exists
if !&config_path.exists() {
return None;
}
let mut config_string: String = String::from_utf8(std::fs::read(&config_path).unwrap()).unwrap();
config_string = config_string.replace("Options", "default").replace("True", "1").replace("False", "0");
std::fs::write(&config_path, config_string).unwrap();
Some(config_path)
}
fn default() {
set("default", "frame", "50");
set("default", "delay", "0");

View File

@ -21,6 +21,7 @@ fn main() {
}
let builder: Builder = Builder::from_file(Path::new("windows/ui.glade"));
config_management::merge_previous_version();
config_management::initialize();
// get Objects from UI