Reading and writing settings through UI

This commit is contained in:
Philip Kristoffersen
2021-10-02 13:45:52 +02:00
parent da4531ecaf
commit 088016843d
14 changed files with 195 additions and 82 deletions
+30 -23
View File
@@ -4,7 +4,7 @@ use std::env::{self};
use std::fs::{DirEntry, File};
use std::io::BufReader;
use std::path::Path;
use std::path::{Path, PathBuf};
use failure::*;
@@ -64,31 +64,38 @@ fn get_manifest_dir_path(
});
}
} else {
#[cfg(target_os = "linux")]
{
//No path defined for epic gamestore, and we cannot guess on linux
Err(PathNotDefined)
let path = get_default_location();
match path {
Some(path) => Ok(path.to_str().unwrap().to_string()),
None => Err(PathNotDefined),
}
}
}
#[cfg(target_os = "windows")]
{
let key = "SYSTEMDRIVE";
let system_drive =
env::var(key).expect("We are on windows, we must know what the SYSTEMDRIVE is");
pub fn get_default_location() -> Option<PathBuf> {
#[cfg(target_os = "linux")]
{
//No path defined for epic gamestore, and we cannot guess on linux
None
}
let path = Path::new(format!("{}\\",system_drive).as_str())
.join("ProgramData")
.join("Epic")
.join("EpicGamesLauncher")
.join("Data")
.join("Manifests");
if path.exists() {
return Ok(path.to_str().unwrap().to_string());
} else {
return Err(PathNotFound {
path: path.to_str().unwrap().to_string(),
});
}
#[cfg(target_os = "windows")]
{
let key = "SYSTEMDRIVE";
let system_drive =
env::var(key).expect("We are on windows, we must know what the SYSTEMDRIVE is");
let path = Path::new(format!("{}\\", system_drive).as_str())
.join("ProgramData")
.join("Epic")
.join("EpicGamesLauncher")
.join("Data")
.join("Manifests");
if path.exists() {
Some(path)
} else {
None
}
}
}
+1
View File
@@ -5,5 +5,6 @@ mod epic_platform;
pub(crate) use manifest_item::*;
use get_manifests::get_egs_manifests;
pub use get_manifests::get_default_location;
pub use settings::EpicGamesLauncherSettings;
pub use epic_platform::*;
+2 -2
View File
@@ -1,6 +1,6 @@
use serde::Deserialize;
use serde::{Serialize,Deserialize};
#[derive(Debug, Deserialize,Clone)]
#[derive(Debug,Serialize, Deserialize,Clone)]
pub struct EpicGamesLauncherSettings {
pub enabled: bool,
pub location: Option<String>,