From 7b1bb1da0fc7599f8b7fdd6d9399fa12c9488b4c Mon Sep 17 00:00:00 2001 From: Lewis Date: Mon, 24 Feb 2025 00:06:36 -0800 Subject: [PATCH 1/2] 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(); From 0d71f3f93b34fd447d0bde8abe86bb9b396e1af7 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Mon, 24 Feb 2025 06:57:18 -0600 Subject: [PATCH 2/2] Also fix the changed Linux paths --- Core/SteamLibrary.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/SteamLibrary.cs b/Core/SteamLibrary.cs index afcfaa5ea..b44e0a255 100644 --- a/Core/SteamLibrary.cs +++ b/Core/SteamLibrary.cs @@ -117,7 +117,7 @@ private static string GetMacOSApplicationDataFolder() // 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), + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support"); #endif } @@ -135,9 +135,9 @@ 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[]