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
62
src/main.rs
62
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;
|
||||||
|
@ -110,7 +111,7 @@ fn main() {
|
||||||
let path = lol_champs_dir.join(&champ_id).join("Recommended");
|
let path = lol_champs_dir.join(&champ_id).join("Recommended");
|
||||||
fs::create_dir_all(&path).unwrap();
|
fs::create_dir_all(&path).unwrap();
|
||||||
if positions.is_empty() {
|
if positions.is_empty() {
|
||||||
error!("{} missing positions", &champ_id);
|
error!("{} missing positions", &champ_id);
|
||||||
}
|
}
|
||||||
for pos in positions {
|
for pos in positions {
|
||||||
data_source.write_item_set(
|
data_source.write_item_set(
|
||||||
|
@ -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");
|
||||||
.enum_keys()
|
if node.is_ok() {
|
||||||
.map(|x| x.unwrap())
|
let val: String = node?.get_value("LocalRootFolder")?;
|
||||||
.find(|x| x == "Riot Game league_of_legends.live");
|
return Ok(PathBuf::from(val).parent().unwrap().to_path_buf());
|
||||||
|
} else {
|
||||||
if key == None {
|
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Riot Games, Inc\League of Legends");
|
||||||
return Err(Error::new(ErrorKind::NotFound, ""));
|
if node.is_ok() {
|
||||||
|
let val: String = node?.get_value("Location")?;
|
||||||
|
return Ok(PathBuf::from(val));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node.open_subkey(key.unwrap())?;
|
let node = hklm.open_subkey(r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
|
||||||
let val: String = node.get_value("InstallLocation")?;
|
let mut sub_node: io::Result<RegKey> = Err(Error::from(ErrorKind::NotFound));
|
||||||
Ok(PathBuf::from(val).join("Config").join("Champions"))
|
|
||||||
|
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()
|
||||||
|
.map(|x| x.unwrap())
|
||||||
|
.find(|x| x == "Riot Game league_of_legends.live");
|
||||||
|
if key.is_some() {
|
||||||
|
sub_node = n.open_subkey(key.unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if sub_node.is_ok() {
|
||||||
|
let val: String = sub_node?.get_value("InstallLocation")?;
|
||||||
|
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