Skip to content

Commit

Permalink
Steam: Remove parsing for "mounted" value in libraryfolders.vdf
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Jul 30, 2021
1 parent d732a1b commit c4c3b48
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions GameFinder.StoreHandlers.Steam/SteamHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public bool TryGetByID(int id, [MaybeNullWhen(false)] out SteamGame? game)
private static readonly Regex SteamConfigRegex = new Regex(@"\""BaseInstallFolder_\d*\""\s*\""(?<path>[^\""]*)\""", RegexOptions.Compiled);
private static readonly Regex OldLibraryFoldersRegex = new Regex(@"^\s+\""\d+\""\s+\""(?<path>.+)\""", RegexOptions.Multiline | RegexOptions.Compiled);
private static readonly Regex NewLibraryFoldersPathRegex = new Regex(@"\""path\""\s*\""(?<path>[^\""]*)\""", RegexOptions.Compiled);
private static readonly Regex NewLibraryFoldersMountedRegex = new Regex(@"\""mounted\""\s*\""(?<mounted>[^\""]*)\""", RegexOptions.Compiled);

internal static List<string> ParseSteamConfig(string file, ILogger logger)
{
Expand Down Expand Up @@ -274,47 +273,17 @@ internal static List<string> ParseLibraryFolders(string file, ILogger logger)
var text = File.ReadAllText(file, Encoding.UTF8);

var pathMatches = NewLibraryFoldersPathRegex.Matches(text);
var mountedMatches = NewLibraryFoldersMountedRegex.Matches(text);

if (pathMatches.Count == 0)
{
logger.LogWarning("Found no path-matches in Library Folders file at {Path}", file);
return res;
}

if (mountedMatches.Count == 0)
{
logger.LogWarning("Found no mounted-matches in Library Folders file at {Path}", file);
return res;
}

if (pathMatches.Count != mountedMatches.Count)
{
logger.LogError("Number of path matches does not equal number of mounted matches in Library Folders file at {Path}", file);
return res;
}

var pathValues = new List<string>();
var mountedValues = new List<string>();

GetAllMatches("path", pathMatches, path => pathValues.Add(path));
GetAllMatches("mounted", mountedMatches, mounted => mountedValues.Add(mounted));

if (pathValues.Count != mountedValues.Count)
{
logger.LogError("Number of path values does not equal number of mounted values in Library Folders file at {Path}", file);
return res;
}

for (var i = 0; i < pathValues.Count; i++)
{
var path = pathValues[i];
var sMounted = mountedValues[i];
if (sMounted != "1") continue;

res.Add(MakeValidPath(path));
}

res.AddRange(pathValues.Select(MakeValidPath));
return res;
}

Expand Down

0 comments on commit c4c3b48

Please sign in to comment.