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
This commit is contained in:
YoshiRulz 2022-07-22 06:05:21 +10:00
parent 0309cdc4bc
commit 41d46dd37d
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 6 additions and 9 deletions

View File

@ -267,7 +267,7 @@
<Rule Id="MA0051" Action="Hidden" />
<!-- Replace constant Enum.ToString with nameof -->
<Rule Id="MA0052" Action="Hidden" />
<Rule Id="MA0052" Action="Error" />
<!-- Make class sealed -->
<Rule Id="MA0053" Action="Hidden" />

View File

@ -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"];

View File

@ -169,6 +169,9 @@ namespace BizHawk.Common.PathExtensions
/// <remarks>returned string omits trailing slash</remarks>
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);