diff --git a/src/main.rs b/src/main.rs index d3f559e..09292d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -137,39 +137,24 @@ fn get_champ_from_key(champs: &Champion, key: &String) -> String { #[cfg(target_os = "windows")] fn lol_champ_dir() -> Result { - 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")); + let key = node + .enum_keys() + .map(|x| x.unwrap()) + .find(|x| x == "Riot Game league_of_legends.live"); - if key == None { - return Err(Error::new(ErrorKind::NotFound, "")); - } - - node = node.open_subkey(key.unwrap())?; - let val: String = node.get_value("InstallLocation")?; - path = PathBuf::from(val); - } + if key == None { + return Err(Error::new(ErrorKind::NotFound, "")); } - Ok(path.join("Config").join("Champions")) + + node = node.open_subkey(key.unwrap())?; + let val: String = node.get_value("InstallLocation")?; + Ok(PathBuf::from(val).join("Config").join("Champions")) } #[cfg(not(target_os = "windows"))] fn lol_champ_dir() -> Result { - Ok(PathBuf::from("./champs")) + Ok(PathBuf::from(LOL_CHAMPS_DIR)) }