summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs16
-rw-r--r--src/SMAPI.Toolkit/Utilities/CaseInsensitivePathLookup.cs10
2 files changed, 20 insertions, 6 deletions
diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
index 12333c4e..84329f63 100644
--- a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using StardewModdingAPI.Toolkit.Serialization;
using StardewModdingAPI.Toolkit.Serialization.Models;
+using StardewModdingAPI.Toolkit.Utilities;
namespace StardewModdingAPI.Toolkit.Framework.ModScanning
{
@@ -251,8 +252,19 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
{
while (true)
{
- // check for manifest in current folder
- FileInfo file = new(Path.Combine(folder.FullName, "manifest.json"));
+ // check for conventional manifest in current folder
+ const string defaultName = "manifest.json";
+ FileInfo file = new(Path.Combine(folder.FullName, defaultName));
+ if (file.Exists)
+ return file;
+
+ // check for manifest with incorrect capitalization
+ {
+ CaseInsensitivePathLookup pathLookup = new(folder.FullName, SearchOption.TopDirectoryOnly); // don't use GetCachedFor, since we only need it temporarily
+ string realName = pathLookup.GetFilePath(defaultName);
+ if (realName != defaultName)
+ file = new(Path.Combine(folder.FullName, realName));
+ }
if (file.Exists)
return file;
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
*********/
/// <summary>Construct an instance.</summary>
/// <param name="rootPath">The root directory path for relative paths.</param>
- public CaseInsensitivePathLookup(string rootPath)
+ /// <param name="searchOption">Which directories to scan from the root.</param>
+ public CaseInsensitivePathLookup(string rootPath, SearchOption searchOption = SearchOption.AllDirectories)
{
this.RootPath = rootPath;
- this.RelativePathCache = new(this.GetRelativePathCache);
+ this.RelativePathCache = new(() => this.GetRelativePathCache(searchOption));
}
/// <summary>Get the exact capitalization for a given relative file path.</summary>
@@ -108,11 +109,12 @@ namespace StardewModdingAPI.Toolkit.Utilities
}
/// <summary>Get a case-insensitive lookup of file paths (see <see cref="RelativePathCache"/>).</summary>
- private Dictionary<string, string> GetRelativePathCache()
+ /// <param name="searchOption">Which directories to scan from the root.</param>
+ private Dictionary<string, string> GetRelativePathCache(SearchOption searchOption)
{
Dictionary<string, string> 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);