Skip to content

Commit

Permalink
Merge #4322 Fix searching for Steam in .NET 8 by correcting path on m…
Browse files Browse the repository at this point in the history
…acOS
  • Loading branch information
HebaruSan committed Feb 24, 2025
2 parents 430cfa8 + 0d71f3f commit 8036473
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ All notable changes to this project will be documented in this file.
- [Core] Handle paths without DriveInfo (#4300 by: HebaruSan)
- [GUI] Make versions tab non-interactive inside install flow (#4302 by: HebaruSan)
- [GUI] Guard rail for clicking refresh with refresh already in progress (#4303 by: HebaruSan)
- [Core] Fix searching for Steam in .NET 8 by correcting path on macOS (#4322 by: doinkythederp; reviewed: HebaruSan)

### Internal

Expand Down
30 changes: 24 additions & 6 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.UserProfile),
"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 @@ -116,15 +135,14 @@ private static string[] SteamPaths
}
: Platform.IsUnix ? new string[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),
".local", "share", "Steam"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Steam"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
".steam", "steam"),
}
: 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 8036473

Please sign in to comment.