From f93c41f55c199293b4b8e00fc38ab89d24837f03 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 16 Apr 2022 14:28:20 -0400 Subject: make manifest.json filename case-insensitive --- src/SMAPI.Toolkit/Utilities/CaseInsensitivePathLookup.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/SMAPI.Toolkit/Utilities') diff --git a/src/SMAPI.Toolkit/Utilities/CaseInsensitivePathLookup.cs b/src/SMAPI.Toolkit/Utilities/CaseInsensitivePathLookup.cs index 2e149e3c..12fad008 100644 --- a/src/SMAPI.Toolkit/Utilities/CaseInsensitivePathLookup.cs +++ b/src/SMAPI.Toolkit/Utilities/CaseInsensitivePathLookup.cs @@ -25,10 +25,11 @@ namespace StardewModdingAPI.Toolkit.Utilities *********/ /// Construct an instance. /// The root directory path for relative paths. - public CaseInsensitivePathLookup(string rootPath) + /// Which directories to scan from the root. + public CaseInsensitivePathLookup(string rootPath, SearchOption searchOption = SearchOption.AllDirectories) { this.RootPath = rootPath; - this.RelativePathCache = new(this.GetRelativePathCache); + this.RelativePathCache = new(() => this.GetRelativePathCache(searchOption)); } /// Get the exact capitalization for a given relative file path. @@ -108,11 +109,12 @@ namespace StardewModdingAPI.Toolkit.Utilities } /// Get a case-insensitive lookup of file paths (see ). - private Dictionary GetRelativePathCache() + /// Which directories to scan from the root. + private Dictionary GetRelativePathCache(SearchOption searchOption) { Dictionary cache = new(StringComparer.OrdinalIgnoreCase); - foreach (string path in Directory.EnumerateFiles(this.RootPath, "*", SearchOption.AllDirectories)) + foreach (string path in Directory.EnumerateFiles(this.RootPath, "*", searchOption)) { string relativePath = path.Substring(this.RootPath.Length + 1); -- cgit