Fix reg key
This commit is contained in:
parent
215f922020
commit
b8b6d78951
1 changed files with 13 additions and 28 deletions
25
src/main.rs
25
src/main.rs
|
@ -137,25 +137,13 @@ fn get_champ_from_key(champs: &Champion, key: &String) -> String {
|
|||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn lol_champ_dir() -> Result<PathBuf, Error> {
|
||||
let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
|
||||
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS");
|
||||
let path: PathBuf;
|
||||
if node.is_ok() {
|
||||
let val: String = node?.get_value("LocalRootFolder")?;
|
||||
path = 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")?;
|
||||
path = PathBuf::from(val);
|
||||
} else {
|
||||
let mut node = hklm
|
||||
.open_subkey(r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall")?;
|
||||
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
|
||||
let mut node = hklm.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\")?;
|
||||
|
||||
let key = node
|
||||
.enum_keys()
|
||||
.map(|x| x.unwrap())
|
||||
.find(|x| x.starts_with("League of Legends"));
|
||||
.find(|x| x == "Riot Game league_of_legends.live");
|
||||
|
||||
if key == None {
|
||||
return Err(Error::new(ErrorKind::NotFound, ""));
|
||||
|
@ -163,13 +151,10 @@ fn lol_champ_dir() -> Result<PathBuf, Error> {
|
|||
|
||||
node = node.open_subkey(key.unwrap())?;
|
||||
let val: String = node.get_value("InstallLocation")?;
|
||||
path = PathBuf::from(val);
|
||||
}
|
||||
}
|
||||
Ok(path.join("Config").join("Champions"))
|
||||
Ok(PathBuf::from(val).join("Config").join("Champions"))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn lol_champ_dir() -> Result<PathBuf, Error> {
|
||||
Ok(PathBuf::from("./champs"))
|
||||
Ok(PathBuf::from(LOL_CHAMPS_DIR))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue