mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Windows clippy (#322)
* Remove indexing * Remove more indexing and expects on windows
This commit is contained in:
@@ -84,6 +84,7 @@ fn get_manifest_item(dir_entry: DirEntry, _path: Option<PathBuf>) -> Option<Mani
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
fn replace_with_dosdevices(compat_folder: &Path, location: &str) -> String {
|
fn replace_with_dosdevices(compat_folder: &Path, location: &str) -> String {
|
||||||
let drive = location.get(0..2).map(|drive| drive.to_lowercase());
|
let drive = location.get(0..2).map(|drive| drive.to_lowercase());
|
||||||
let rest_path = location.get(3..).map(|rest| rest.replace('\\', "/"));
|
let rest_path = location.get(3..).map(|rest| rest.replace('\\', "/"));
|
||||||
|
|||||||
+16
-26
@@ -110,52 +110,42 @@ mod windows {
|
|||||||
|
|
||||||
fn guess_default_launcher_location() -> PathBuf {
|
fn guess_default_launcher_location() -> PathBuf {
|
||||||
let key = "SYSTEMDRIVE";
|
let key = "SYSTEMDRIVE";
|
||||||
let system_drive =
|
let system_drive = env::var(key).unwrap_or_else(|_| String::from("c:"));
|
||||||
env::var(key).expect("We are on windows, we must know what the SYSTEMDRIVE is");
|
Path::new(format!("{}\\", system_drive).as_str())
|
||||||
|
|
||||||
let path = Path::new(format!("{}\\", system_drive).as_str())
|
|
||||||
.join("Program Files (x86)")
|
.join("Program Files (x86)")
|
||||||
.join("Epic Games")
|
.join("Epic Games")
|
||||||
.join("Launcher")
|
.join("Launcher")
|
||||||
.join("Portal")
|
.join("Portal")
|
||||||
.join("Binaries")
|
.join("Binaries")
|
||||||
.join("Win64")
|
.join("Win64")
|
||||||
.join("EpicGamesLauncher.exe");
|
.join("EpicGamesLauncher.exe")
|
||||||
path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn launcher_location_from_registry() -> Option<PathBuf> {
|
fn launcher_location_from_registry() -> Option<PathBuf> {
|
||||||
use winreg::enums::*;
|
use winreg::enums::*;
|
||||||
use winreg::RegKey;
|
use winreg::RegKey;
|
||||||
|
|
||||||
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
|
RegKey::predef(HKEY_LOCAL_MACHINE)
|
||||||
|
.open_subkey("SOFTWARE\\Classes\\com.epicgames.launcher\\shell\\open\\command")
|
||||||
if let Ok(launcher) =
|
.ok()
|
||||||
hklm.open_subkey("SOFTWARE\\Classes\\com.epicgames.launcher\\shell\\open\\command")
|
.and_then(|launcher| launcher.get_value("").ok())
|
||||||
{
|
.and_then(|value: String| {
|
||||||
let launch_string: Result<String, _> = launcher.get_value("");
|
value
|
||||||
if let Ok(launch_string) = launch_string {
|
.get(1..value.len() - 4)
|
||||||
let path = Path::new(&launch_string[1..launch_string.len() - 4]);
|
.map(|path| Path::new(path).to_path_buf())
|
||||||
if path.exists() {
|
})
|
||||||
return Some(path.to_path_buf());
|
.filter(|path| path.exists())
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn guess_default_manifest_location() -> PathBuf {
|
fn guess_default_manifest_location() -> PathBuf {
|
||||||
let key = "SYSTEMDRIVE";
|
let key = "SYSTEMDRIVE";
|
||||||
let system_drive =
|
let system_drive = env::var(key).unwrap_or_else(|_| String::from("c:"));
|
||||||
env::var(key).expect("We are on windows, we must know what the SYSTEMDRIVE is");
|
Path::new(format!("{}\\", system_drive).as_str())
|
||||||
|
|
||||||
let path = Path::new(format!("{}\\", system_drive).as_str())
|
|
||||||
.join("ProgramData")
|
.join("ProgramData")
|
||||||
.join("Epic")
|
.join("Epic")
|
||||||
.join("EpicGamesLauncher")
|
.join("EpicGamesLauncher")
|
||||||
.join("Data")
|
.join("Data")
|
||||||
.join("Manifests");
|
.join("Manifests")
|
||||||
path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_locations() -> Option<EpicPaths> {
|
pub fn get_locations() -> Option<EpicPaths> {
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ impl NeedsPorton<OriginPlatform> for OriginGame {
|
|||||||
|
|
||||||
impl OriginPlatform {
|
impl OriginPlatform {
|
||||||
fn get_shortcuts(&self) -> eyre::Result<Vec<OriginGame>> {
|
fn get_shortcuts(&self) -> eyre::Result<Vec<OriginGame>> {
|
||||||
let origin_folders = get_default_locations().ok_or(eyre::format_err!("Default path not found"))?;
|
let origin_folders =
|
||||||
|
get_default_locations().ok_or(eyre::format_err!("Default path not found"))?;
|
||||||
let origin_folder = origin_folders.local_content_path;
|
let origin_folder = origin_folders.local_content_path;
|
||||||
let origin_exe = origin_folders.exe_path;
|
let origin_exe = origin_folders.exe_path;
|
||||||
let game_folders = origin_folder.join("LocalContent").read_dir()?;
|
let game_folders = origin_folder.join("LocalContent").read_dir()?;
|
||||||
@@ -164,18 +165,16 @@ fn get_exe_path() -> Option<PathBuf> {
|
|||||||
use winreg::enums::*;
|
use winreg::enums::*;
|
||||||
use winreg::RegKey;
|
use winreg::RegKey;
|
||||||
//Computer\HKEY_CLASSES_ROOT\eadm\shell\open\command
|
//Computer\HKEY_CLASSES_ROOT\eadm\shell\open\command
|
||||||
|
RegKey::predef(HKEY_CLASSES_ROOT)
|
||||||
let hklm = RegKey::predef(HKEY_CLASSES_ROOT);
|
.open_subkey("eadm\\shell\\open\\command")
|
||||||
if let Ok(launcher_key) = hklm.open_subkey("eadm\\shell\\open\\command") {
|
.and_then(|launcher_key| launcher_key.get_value(""))
|
||||||
let launcher_string: Result<String, _> = launcher_key.get_value("");
|
.ok()
|
||||||
if let Ok(launcher_string) = launcher_string {
|
.and_then(|value: String| {
|
||||||
let path = Path::new(&launcher_string[1..launcher_string.len() - 6]);
|
value
|
||||||
if path.exists() {
|
.get(1..value.len() - 6)
|
||||||
return Some(path.to_path_buf());
|
.map(|path_str| Path::new(path_str).to_path_buf())
|
||||||
}
|
})
|
||||||
}
|
.filter(|path| path.exists())
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GamesPlatform for OriginPlatform {
|
impl GamesPlatform for OriginPlatform {
|
||||||
|
|||||||
Reference in New Issue
Block a user