From dff75c2bb6f8bd5c31334d1d2d60a25b7a1f2020 Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Mon, 14 Jun 2021 17:34:08 -0400 Subject: [PATCH] Fix for games installed in another library folder --- DeliCounter/Backend/Services/SteamAppLocator.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DeliCounter/Backend/Services/SteamAppLocator.cs b/DeliCounter/Backend/Services/SteamAppLocator.cs index eb328e0..d0d4202 100644 --- a/DeliCounter/Backend/Services/SteamAppLocator.cs +++ b/DeliCounter/Backend/Services/SteamAppLocator.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Text.RegularExpressions; namespace DeliCounter.Backend { @@ -78,17 +79,15 @@ public void Locate() { // We didn't find it, look at other library folders by lazily parsing libraryfolders. var libraryFolders = Path.Combine(steamDir, @"steamapps\libraryfolders.vdf"); - foreach (var ii in File.ReadAllLines(libraryFolders).Skip(4) - .Where(x => x.Length != 0 && x[0] != '}') - .Select(x => x.Split('\t')[3].Trim('"').Replace(@"\\", @"\")).Where(ii => - File.Exists(ii + $@"\steamapps\appmanifest_{AppId}.acf"))) + foreach (Match match in Regex.Matches(File.ReadAllText(libraryFolders), @"^\s+\""path\""\s+\""(.+)\""$", RegexOptions.Multiline)) { - result = Path.Combine(ii, $@"steamapps\common\{AppFolderName}\"); - break; + var folder = match.Groups[1].Value; + if (!File.Exists(Path.Combine(folder, $"steamapps/appmanifest_{AppId}.acf"))) continue; + result = Path.Combine(folder, $"steamapps/common/{AppFolderName}"); } } - AppLocation = string.IsNullOrEmpty(result) ? null : result; + AppLocation = string.IsNullOrEmpty(result) ? null : Path.GetFullPath(result); } } } \ No newline at end of file