diff --git a/CHANGELOG.md b/CHANGELOG.md index 55e6b8f68..fd02e9288 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Core/SteamLibrary.cs b/Core/SteamLibrary.cs index 5623421dd..b44e0a255 100644 --- a/Core/SteamLibrary.cs +++ b/Core/SteamLibrary.cs @@ -2,7 +2,7 @@ using System.IO; using System.Linq; using System.Collections.Generic; - +using System.Diagnostics; using log4net; using ValveKeyValue; @@ -103,6 +103,25 @@ private static IEnumerable ShortcutsFileGames(KVSerializer vdfParser, .Select(nsg => nsg.NormalizeDir(path)) ?? Enumerable.Empty(); + /// + /// Find the location where the current user's application data resides. Specific to macOS. + /// + /// + /// The application data folder, e.g. /Users/USER/Library/Application Support + /// + 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 @@ -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();