mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Read install folders (#130)
This commit is contained in:
Generated
+2
-2
@@ -2600,9 +2600,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.1"
|
version = "0.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0edfdeb067411dba2044da6d1cb2df793dd35add7888d73c16e3381ded401764"
|
checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::{ffi::OsStr, path::Path};
|
use std::{ffi::OsStr, path::{Path, PathBuf}};
|
||||||
|
|
||||||
use super::{get_steam_path, SteamSettings};
|
use super::{get_steam_path, SteamSettings};
|
||||||
|
|
||||||
@@ -9,11 +9,10 @@ pub struct SteamGameInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_installed_games(settings: &SteamSettings) -> Vec<SteamGameInfo> {
|
pub fn get_installed_games(settings: &SteamSettings) -> Vec<SteamGameInfo> {
|
||||||
let path = get_steam_path(settings);
|
let install_folders = get_install_folders(settings);
|
||||||
if let Ok(path) = path {
|
|
||||||
let apps_path = Path::new(&path).join("steamapps");
|
|
||||||
if let Ok(files) = std::fs::read_dir(apps_path) {
|
|
||||||
let mut games = vec![];
|
let mut games = vec![];
|
||||||
|
for apps_path in install_folders {
|
||||||
|
if let Ok(files) = std::fs::read_dir(apps_path) {
|
||||||
for file in files {
|
for file in files {
|
||||||
if let Ok(file) = file {
|
if let Ok(file) = file {
|
||||||
if let Some(game_info) = parse_manifest_file(&file.path()) {
|
if let Some(game_info) = parse_manifest_file(&file.path()) {
|
||||||
@@ -21,10 +20,33 @@ pub fn get_installed_games(settings: &SteamSettings) -> Vec<SteamGameInfo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
games.sort_by_key(|g| g.name.clone());
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_install_folders(settings: &SteamSettings) -> Vec<PathBuf> {
|
||||||
|
let mut result = vec![];
|
||||||
|
if let Ok(path) = get_steam_path(settings) {
|
||||||
|
let path = Path::new(&path);
|
||||||
|
|
||||||
|
let vdf_path = path.join("steamapps").join("libraryfolders.vdf");
|
||||||
|
if !vdf_path.exists() {
|
||||||
|
result.push(path.join("steamapps").to_path_buf());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
vec![]
|
if let Ok(vdf_file) = std::fs::read_to_string(vdf_path) {
|
||||||
|
for line in vdf_file.lines() {
|
||||||
|
if line.contains("\"path\"") {
|
||||||
|
let path_string = &line[11..line.len() - 1];
|
||||||
|
result.push(Path::new(&path_string).join("steamapps").to_path_buf());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_manifest_file(path: &Path) -> Option<SteamGameInfo> {
|
fn parse_manifest_file(path: &Path) -> Option<SteamGameInfo> {
|
||||||
|
|||||||
Reference in New Issue
Block a user