From 41d46dd37d5d517bf19a925c0d82d56f2a4811c9 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 22 Jul 2022 06:05:21 +1000 Subject: [PATCH] Fix `%recent%` in Paths config broken since introduction in 017743133 (pre-1.0 according to GitHub) also enabled MA0052 "Replace constant Enum.ToString with nameof", which is what tipped me off to this --- Common.ruleset | 2 +- .../config/PathEntryCollectionExtensions.cs | 10 ++-------- src/BizHawk.Common/Extensions/PathExtensions.cs | 3 +++ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Common.ruleset b/Common.ruleset index d661d1c0c1..8b7d3ee3d3 100644 --- a/Common.ruleset +++ b/Common.ruleset @@ -267,7 +267,7 @@ - + diff --git a/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs b/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs index f88b72d6e3..e8ed9d1a93 100644 --- a/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs +++ b/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs @@ -87,10 +87,7 @@ namespace BizHawk.Client.Common return collection.GlobalBaseAbsolutePath(); } - if (path == "%recent%") - { - return Environment.SpecialFolder.Recent.ToString(); - } + if (path == "%recent%") return PathUtils.SpecialRecentsDir; if (path.StartsWith("%exe%")) { @@ -202,10 +199,7 @@ namespace BizHawk.Client.Common return collection.AbsolutePathFor(collection[PathEntryCollection.GLOBAL, "ROM"].Path, PathEntryCollection.GLOBAL); } - if (collection.UseRecentForRoms) - { - return Environment.SpecialFolder.Recent.ToString(); - } + if (collection.UseRecentForRoms) return PathUtils.SpecialRecentsDir; var path = collection[systemId, "ROM"]; diff --git a/src/BizHawk.Common/Extensions/PathExtensions.cs b/src/BizHawk.Common/Extensions/PathExtensions.cs index e091a0cad3..6825d33733 100644 --- a/src/BizHawk.Common/Extensions/PathExtensions.cs +++ b/src/BizHawk.Common/Extensions/PathExtensions.cs @@ -169,6 +169,9 @@ namespace BizHawk.Common.PathExtensions /// returned string omits trailing slash public static readonly string ExeDirectoryPath; + public static string SpecialRecentsDir + => Environment.GetFolderPath(Environment.SpecialFolder.Recent, Environment.SpecialFolderOption.DoNotVerify); + static PathUtils() { var dirPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);