aboutsummaryrefslogtreecommitdiff
path: root/src/extras
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-05-02 21:49:20 +0200
committerGitHub <noreply@github.com>2022-05-02 21:49:20 +0200
commitc40e331bdc4b2375d3802a515c9b7a032118dea7 (patch)
tree77c8d84c0fc9d0fbb742cfeeb80efa4762784a9d /src/extras
parent9f2f77558238c28ceb8ff4fca2096602671779e5 (diff)
parent847a2178e7823749e3096daf24dfcd3df8b236cb (diff)
downloadViper-c40e331bdc4b2375d3802a515c9b7a032118dea7.tar.gz
Viper-c40e331bdc4b2375d3802a515c9b7a032118dea7.zip
Merge branch 'main' into enabledmods
Diffstat (limited to 'src/extras')
-rw-r--r--src/extras/findgame.js36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/extras/findgame.js b/src/extras/findgame.js
index 42c9b85..3beca23 100644
--- a/src/extras/findgame.js
+++ b/src/extras/findgame.js
@@ -31,32 +31,50 @@ module.exports = async () => {
// Parse read_data
data = vdf.parse(data);
+ let values = Object.values(data["libraryfolders"]);
+ if (typeof values[values.length - 1] != "object") {
+ values.pop(1);
+ }
+
// `.length - 1` This is because the last value is `contentstatsid`
- for (let pathIterator = 0; pathIterator < Object.values(data["libraryfolders"]).length - 1; pathIterator++) {
- let data_array = Object.values(data["libraryfolders"][pathIterator])
+ for (let i = 0; i < values.length; i++) {
+ let data_array = Object.values(values[i])
if (fs.existsSync(data_array[0] + "/steamapps/common/Titanfall2/Titanfall2.exe")) {
+ console.log("Found game in:", data_array[0])
return data_array[0] + "/steamapps/common/Titanfall2";
+ } else {
+ console.log("Game not in:", data_array[0])
}
}
}
- let folder = null;
+ let folders = [];
switch (process.platform) {
case "win32":
- folder = "C:\\Program Files (x86)\\Steam\\steamapps\\libraryfolders.vdf";
+ folders = ["C:\\Program Files (x86)\\Steam\\steamapps\\libraryfolders.vdf"];
break
case "linux":
case "openbsd":
case "freebsd":
- folder = path.join(app.getPath("home"), "/.steam/steam/steamapps/libraryfolders.vdf");
+ let home = app.getPath("home");
+ folders = [
+ path.join(home, "/.steam/steam/steamapps/libraryfolders.vdf"),
+ path.join(home, ".var/app/com.valvesoftware.Steam/.steam/steam/steamapps/libraryfolders.vdf"),
+ path.join(home, ".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/libraryfolders.vdf")
+ ]
break
}
- if (fs.existsSync(folder) && folder) {
- let data = fs.readFileSync(folder)
- let read_vdf = readvdf(data.toString())
- if (read_vdf ) {return read_vdf}
+ if (folders.length > 0) {
+ for (let i = 0; i < folders.length; i++) {
+ if (! fs.existsSync(folders[i])) {continue}
+ console.log("Searching VDF file at:", folders[i])
+
+ let data = fs.readFileSync(folders[i])
+ let read_vdf = readvdf(data.toString())
+ if (read_vdf) {return read_vdf}
+ }
}
if (gamepath) {