mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
+20
-20
@@ -8,14 +8,14 @@ use steam_shortcuts_util::{parse_shortcuts, shortcut::ShortcutOwned};
|
||||
|
||||
use super::SteamSettings;
|
||||
|
||||
pub fn get_shortcuts_for_user(user: &SteamUsersInfo) -> ShortcutInfo {
|
||||
pub fn get_shortcuts_for_user(user: &SteamUsersInfo) -> eyre::Result<ShortcutInfo> {
|
||||
let mut shortcuts = vec![];
|
||||
|
||||
let new_path = match &user.shortcut_path {
|
||||
Some(shortcut_path) => {
|
||||
let content = std::fs::read(shortcut_path).unwrap();
|
||||
let content = std::fs::read(shortcut_path)?;
|
||||
shortcuts = parse_shortcuts(content.as_slice())
|
||||
.unwrap()
|
||||
.map_err(|e| eyre::format_err!("Could not parse shortcuts: {:?}", e))?
|
||||
.iter()
|
||||
.map(|s| s.to_owned())
|
||||
.collect();
|
||||
@@ -27,15 +27,15 @@ pub fn get_shortcuts_for_user(user: &SteamUsersInfo) -> ShortcutInfo {
|
||||
user.steam_user_data_folder
|
||||
);
|
||||
let path = Path::new(&user.steam_user_data_folder).join("config");
|
||||
std::fs::create_dir_all(path.clone()).unwrap();
|
||||
std::fs::create_dir_all(path.clone())?;
|
||||
path.join("shortcuts.vdf")
|
||||
}
|
||||
};
|
||||
|
||||
ShortcutInfo {
|
||||
Ok(ShortcutInfo {
|
||||
shortcuts,
|
||||
path: new_path,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub struct ShortcutInfo {
|
||||
@@ -51,22 +51,22 @@ pub struct SteamUsersInfo {
|
||||
}
|
||||
|
||||
/// Get the paths to the steam users shortcuts (one for each user)
|
||||
pub fn get_shortcuts_paths(
|
||||
settings: &SteamSettings,
|
||||
) -> Result<Vec<SteamUsersInfo>, Box<dyn Error + Sync + Send>> {
|
||||
pub fn get_shortcuts_paths(settings: &SteamSettings) -> eyre::Result<Vec<SteamUsersInfo>> {
|
||||
let steam_path_str = get_steam_path(settings)?;
|
||||
let steam_path = Path::new(&steam_path_str);
|
||||
if !steam_path.exists() {
|
||||
return Result::Err(Box::new(SteamFolderNotFound {
|
||||
location_tried: format!("{:?}", steam_path),
|
||||
}));
|
||||
return Err(eyre::format_err!(
|
||||
"Steam folder not found at: {:?}",
|
||||
steam_path
|
||||
));
|
||||
}
|
||||
|
||||
let user_data_path = steam_path.join("userdata");
|
||||
if !user_data_path.exists() {
|
||||
return Result::Err(Box::new(SteamFolderNotFound {
|
||||
location_tried: format!("{:?}", user_data_path),
|
||||
}));
|
||||
return Err(eyre::format_err!(
|
||||
"Steam user data folder not found at: {:?}",
|
||||
user_data_path
|
||||
));
|
||||
}
|
||||
|
||||
if !user_data_path.exists() {}
|
||||
@@ -89,7 +89,7 @@ pub fn get_shortcuts_paths(
|
||||
if shortcuts_path.exists() {
|
||||
return SteamUsersInfo {
|
||||
steam_user_data_folder: folder_string,
|
||||
shortcut_path: Some(shortcuts_path.to_str().unwrap().to_string()),
|
||||
shortcut_path: Some(shortcuts_path.to_string_lossy().to_string()),
|
||||
user_id,
|
||||
};
|
||||
} else {
|
||||
@@ -104,7 +104,7 @@ pub fn get_shortcuts_paths(
|
||||
Ok(users_info)
|
||||
}
|
||||
|
||||
pub fn get_steam_path(settings: &SteamSettings) -> Result<String, Box<dyn Error + Sync + Send>> {
|
||||
pub fn get_steam_path(settings: &SteamSettings) -> eyre::Result<String> {
|
||||
let user_location = settings.location.clone();
|
||||
let steam_path_str = match user_location {
|
||||
Some(location) => location,
|
||||
@@ -113,7 +113,7 @@ pub fn get_steam_path(settings: &SteamSettings) -> Result<String, Box<dyn Error
|
||||
Ok(steam_path_str)
|
||||
}
|
||||
|
||||
pub fn get_default_location() -> Result<String, Box<dyn Error + Sync + Send>> {
|
||||
pub fn get_default_location() -> eyre::Result<String> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let path_string = {
|
||||
let key = "PROGRAMFILES(X86)";
|
||||
@@ -198,8 +198,8 @@ impl Error for SteamUsersDataEmpty {
|
||||
self.location_tried.as_str()
|
||||
}
|
||||
}
|
||||
pub fn get_users_images(user: &SteamUsersInfo) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
let grid_folder = Path::new(user.steam_user_data_folder.as_str()).join("config/grid");
|
||||
pub fn get_users_images(data_folder: &str) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
let grid_folder = Path::new(data_folder).join("config/grid");
|
||||
if !grid_folder.exists() {
|
||||
std::fs::create_dir_all(&grid_folder)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user