[feat] reset modal + basic auto get path + basic wrap err try
This commit is contained in:
@@ -4,6 +4,7 @@ pub mod path;
|
||||
pub mod reg;
|
||||
|
||||
// common steam utils
|
||||
use anyhow::Result;
|
||||
use std::error::Error;
|
||||
use std::process::{Command, Output};
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
// - CS2(CS:GO) Path
|
||||
#![allow(unused)]
|
||||
|
||||
use anyhow::Result;
|
||||
use crate::tool::common::get_exe_path;
|
||||
|
||||
use super::reg;
|
||||
|
||||
pub fn get_steam_path<'a>() -> Result<String, &'a str> {
|
||||
pub fn get_steam_path() -> Result<String, String> {
|
||||
// Windows Registry
|
||||
#[cfg(target_os = "windows")]
|
||||
if let Ok(reg) = reg::SteamReg::get_all() {
|
||||
@@ -20,12 +21,12 @@ pub fn get_steam_path<'a>() -> Result<String, &'a str> {
|
||||
return Ok(steam_path);
|
||||
}
|
||||
|
||||
Err("no steam path found")
|
||||
Err("no steam path found".into())
|
||||
}
|
||||
|
||||
pub fn get_cs_path<'a>(name: &str) -> Result<String, &'a str> {
|
||||
if name != "csgo" || name != "cs2" {
|
||||
return Err("invalid cs name");
|
||||
pub fn get_cs_path(name: &str) -> Result<String, String> {
|
||||
if name != "csgo" && name != "cs2" {
|
||||
return Err("invalid cs name".into());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
@@ -33,7 +34,7 @@ pub fn get_cs_path<'a>(name: &str) -> Result<String, &'a str> {
|
||||
return Ok(cs_path);
|
||||
}
|
||||
|
||||
Err("no cs path found")
|
||||
Err("no cs path found".into())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -29,7 +29,7 @@ impl SteamReg {
|
||||
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
|
||||
let cur_ver = hkcu.open_subkey(STEAM_REG).expect("steam reg");
|
||||
|
||||
let steam_path: String = cur_ver.get_value("SteamExe").expect("steam path");
|
||||
let steam_path: String = cur_ver.get_value("SteamPath").expect("steam path");
|
||||
let auto_login_user: String = cur_ver.get_value("AutoLoginUser").expect("auto login user");
|
||||
let suppress_auto_run: u32 = cur_ver
|
||||
.get_value("SuppressAutoRun")
|
||||
@@ -39,12 +39,12 @@ impl SteamReg {
|
||||
.expect("remember password");
|
||||
let language: String = cur_ver.get_value("Language").expect("language");
|
||||
|
||||
let users = cur_ver
|
||||
.open_subkey("Users")
|
||||
.expect("users")
|
||||
.enum_keys()
|
||||
.map(|x| x.unwrap().to_string())
|
||||
.collect::<Vec<String>>();
|
||||
// let users = cur_ver
|
||||
// .open_subkey("Users")
|
||||
// .expect("users")
|
||||
// .enum_keys()
|
||||
// .map(|x| x.unwrap().to_string())
|
||||
// .collect::<Vec<String>>();
|
||||
|
||||
Ok(Self {
|
||||
steam_path,
|
||||
@@ -52,7 +52,7 @@ impl SteamReg {
|
||||
suppress_auto_run,
|
||||
remember_password,
|
||||
language,
|
||||
users: users,
|
||||
users: vec![],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user