From 7b1bb1da0fc7599f8b7fdd6d9399fa12c9488b4c Mon Sep 17 00:00:00 2001 From: Lewis Date: Mon, 24 Feb 2025 00:06:36 -0800 Subject: [PATCH] fix(.NET 8): search for steam in correct path --- Core/SteamLibrary.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Core/SteamLibrary.cs b/Core/SteamLibrary.cs index 5623421dd..afcfaa5ea 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.MyDocuments), + "Library", "Application Support"); +#endif + } + private const string registryKey = @"HKEY_CURRENT_USER\Software\Valve\Steam"; private const string registryValue = @"SteamPath"; private static string[] SteamPaths @@ -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();