aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-03-24 17:36:20 +0100
committer0neGal <mail@0negal.com>2022-03-24 17:36:20 +0100
commit89fa1d955ccb4ac4133079adc9a775dfabe99942 (patch)
tree5286a99bbd53bb8eb07f09838ab24af06cbbf7d5
parentcd346498a2e9a16a48e55b21ec46e1d08f677c7d (diff)
downloadViper-89fa1d955ccb4ac4133079adc9a775dfabe99942.tar.gz
Viper-89fa1d955ccb4ac4133079adc9a775dfabe99942.zip
support for multiple VDF files
-rw-r--r--src/extras/findgame.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/extras/findgame.js b/src/extras/findgame.js
index 924c96f..3beca23 100644
--- a/src/extras/findgame.js
+++ b/src/extras/findgame.js
@@ -43,36 +43,38 @@ module.exports = async () => {
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":
- let paths = [
- "/.steam/steam/steamapps/libraryfolders.vdf",
- ".var/app/com.valvesoftware.Steam/.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")
]
-
- for (let i = 0; i < paths.length; i++) {
- if (fs.existsSync(path.join(app.getPath("home"), paths[i]))) {
- folder = path.join(app.getPath("home"), paths[i]);
- continue
- }
- }
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) {