support alternative key

This commit is contained in:
nyyu 2018-06-10 12:42:02 +02:00
parent f3503df2ec
commit 71038e9a44

View File

@ -76,6 +76,7 @@ fn main() {
Ok(x) => x,
Err(_e) => PathBuf::from(LOL_CHAMPS_DIR),
};
info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap());
let mut headers = Headers::new();
headers.set(UserAgent::new(USER_AGENT));
@ -276,11 +277,15 @@ fn write_item_set(
fn lol_champ_dir() -> Result<PathBuf, io::Error> {
let hklm = RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS")?;
let dir: String = node.get_value("LocalRootFolder")?;
Ok(PathBuf::from(&dir)
.parent()
.unwrap()
.join("Config")
.join("Champions"))
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");
let val: String = node?.get_value("Location")?;
path = PathBuf::from(val);
}
Ok(path.join("Config").join("Champions"))
}