Readd old regkey for old install
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
a723ec1609
commit
b08dd9c6c0
1 changed files with 49 additions and 13 deletions
54
src/main.rs
54
src/main.rs
|
@ -2,6 +2,7 @@ use indexmap::IndexMap;
|
||||||
use log::{error, info, LevelFilter};
|
use log::{error, info, LevelFilter};
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
|
use std::io;
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
|
@ -140,21 +141,56 @@ fn get_champ_from_key(champs: &Champion, key: &str) -> String {
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn lol_champ_dir() -> Result<PathBuf, Error> {
|
fn lol_champ_dir() -> Result<PathBuf, Error> {
|
||||||
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
|
let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
|
||||||
let mut node = hklm.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\")?;
|
|
||||||
|
|
||||||
let key = node
|
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS");
|
||||||
|
if node.is_ok() {
|
||||||
|
let val: String = node?.get_value("LocalRootFolder")?;
|
||||||
|
return Ok(PathBuf::from(val).parent().unwrap().to_path_buf());
|
||||||
|
} else {
|
||||||
|
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games, Inc\League of Legends");
|
||||||
|
if node.is_ok() {
|
||||||
|
let val: String = node?.get_value("Location")?;
|
||||||
|
return Ok(PathBuf::from(val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
|
||||||
|
let mut sub_node: io::Result<RegKey> = Err(Error::from(ErrorKind::NotFound));
|
||||||
|
|
||||||
|
if node.is_ok() {
|
||||||
|
let n = node.unwrap();
|
||||||
|
let key = n
|
||||||
|
.enum_keys()
|
||||||
|
.map(|x| x.unwrap())
|
||||||
|
.find(|x| x.starts_with("League of Legends"));
|
||||||
|
if key.is_some() {
|
||||||
|
sub_node = n.open_subkey(key.unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if sub_node.is_err() {
|
||||||
|
let hkcu = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
|
||||||
|
let node = hkcu.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\");
|
||||||
|
if node.is_ok() {
|
||||||
|
let n = node.unwrap();
|
||||||
|
let key = n
|
||||||
.enum_keys()
|
.enum_keys()
|
||||||
.map(|x| x.unwrap())
|
.map(|x| x.unwrap())
|
||||||
.find(|x| x == "Riot Game league_of_legends.live");
|
.find(|x| x == "Riot Game league_of_legends.live");
|
||||||
|
if key.is_some() {
|
||||||
if key == None {
|
sub_node = n.open_subkey(key.unwrap());
|
||||||
return Err(Error::new(ErrorKind::NotFound, ""));
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node.open_subkey(key.unwrap())?;
|
if sub_node.is_ok() {
|
||||||
let val: String = node.get_value("InstallLocation")?;
|
let val: String = sub_node?.get_value("InstallLocation")?;
|
||||||
Ok(PathBuf::from(val).join("Config").join("Champions"))
|
return Ok(PathBuf::from(val).join("Config").join("Champions"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Err(Error::from(ErrorKind::NotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
|
Loading…
Add table
Reference in a new issue