Skip to content

Commit

Permalink
fix(.NET 8): search for steam in correct path
Browse files Browse the repository at this point in the history
  • Loading branch information
doinkythederp committed Feb 24, 2025
1 parent 430cfa8 commit 7b1bb1d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Core/SteamLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using System.Linq;
using System.Collections.Generic;

using System.Diagnostics;
using log4net;
using ValveKeyValue;

Expand Down Expand Up @@ -103,6 +103,25 @@ private static IEnumerable<GameBase> ShortcutsFileGames(KVSerializer vdfParser,
.Select(nsg => nsg.NormalizeDir(path))
?? Enumerable.Empty<NonSteamGame>();

/// <summary>
/// Find the location where the current user's application data resides. Specific to macOS.
/// </summary>
/// <returns>
/// The application data folder, e.g. <code>/Users/USER/Library/Application Support</code>
/// </returns>
private static string GetMacOSApplicationDataFolder()
{
Debug.Assert(Platform.IsMac);

#if NET8_0_OR_GREATER
// https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/8.0/getfolderpath-unix
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
#else
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"Library", "Application Support");
#endif
}

private const string registryKey = @"HKEY_CURRENT_USER\Software\Valve\Steam";
private const string registryValue = @"SteamPath";
private static string[] SteamPaths
Expand All @@ -123,8 +142,7 @@ private static string[] SteamPaths
}
: Platform.IsMac ? new string[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),
"Library", "Application Support", "Steam"),
Path.Combine(GetMacOSApplicationDataFolder(), "Steam"),
}
: Array.Empty<string>();

Expand Down

0 comments on commit 7b1bb1d

Please sign in to comment.