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")]
|
#[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_LOCAL_MACHINE);
|
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
|
||||||
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games\RADS");
|
let mut node = hklm.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\")?;
|
||||||
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 key = node
|
let key = node
|
||||||
.enum_keys()
|
.enum_keys()
|
||||||
.map(|x| x.unwrap())
|
.map(|x| x.unwrap())
|
||||||
.find(|x| x.starts_with("League of Legends"));
|
.find(|x| x == "Riot Game league_of_legends.live");
|
||||||
|
|
||||||
if key == None {
|
if key == None {
|
||||||
return Err(Error::new(ErrorKind::NotFound, ""));
|
return Err(Error::new(ErrorKind::NotFound, ""));
|
||||||
|
@ -163,13 +151,10 @@ fn lol_champ_dir() -> Result<PathBuf, Error> {
|
||||||
|
|
||||||
node = node.open_subkey(key.unwrap())?;
|
node = node.open_subkey(key.unwrap())?;
|
||||||
let val: String = node.get_value("InstallLocation")?;
|
let val: String = node.get_value("InstallLocation")?;
|
||||||
path = PathBuf::from(val);
|
Ok(PathBuf::from(val).join("Config").join("Champions"))
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(path.join("Config").join("Champions"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
fn lol_champ_dir() -> Result<PathBuf, Error> {
|
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