From c1342bd4cd6b75b24d11275bdd73ebf893f916ea Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 4 May 2022 20:35:08 -0400 Subject: disable case-insensitive paths by default pending performance rework --- src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/SMAPI.Toolkit/Framework') diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs index 24485620..aa4c3338 100644 --- a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs +++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text.RegularExpressions; using StardewModdingAPI.Toolkit.Serialization; using StardewModdingAPI.Toolkit.Serialization.Models; -using StardewModdingAPI.Toolkit.Utilities; +using StardewModdingAPI.Toolkit.Utilities.PathLookups; namespace StardewModdingAPI.Toolkit.Framework.ModScanning { @@ -95,19 +95,20 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning /// Extract information about all mods in the given folder. /// The root folder containing mods. - public IEnumerable GetModFolders(string rootPath) + /// Whether to match file paths case-insensitively, even on Linux. + public IEnumerable GetModFolders(string rootPath, bool useCaseInsensitiveFilePaths) { DirectoryInfo root = new(rootPath); - return this.GetModFolders(root, root); + return this.GetModFolders(root, root, useCaseInsensitiveFilePaths); } /// Extract information about all mods in the given folder. /// The root folder containing mods. Only the will be searched, but this field allows it to be treated as a potential mod folder of its own. /// The mod path to search. - // /// If the folder contains multiple XNB mods, treat them as subfolders of a single mod. This is useful when reading a single mod archive, as opposed to a mods folder. - public IEnumerable GetModFolders(string rootPath, string modPath) + /// Whether to match file paths case-insensitively, even on Linux. + public IEnumerable GetModFolders(string rootPath, string modPath, bool useCaseInsensitiveFilePaths) { - return this.GetModFolders(root: new DirectoryInfo(rootPath), folder: new DirectoryInfo(modPath)); + return this.GetModFolders(root: new DirectoryInfo(rootPath), folder: new DirectoryInfo(modPath), useCaseInsensitiveFilePaths: useCaseInsensitiveFilePaths); } /// Extract information from a mod folder. @@ -195,7 +196,8 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning /// Recursively extract information about all mods in the given folder. /// The root mod folder. /// The folder to search for mods. - private IEnumerable GetModFolders(DirectoryInfo root, DirectoryInfo folder) + /// Whether to match file paths case-insensitively, even on Linux. + private IEnumerable GetModFolders(DirectoryInfo root, DirectoryInfo folder, bool useCaseInsensitiveFilePaths) { bool isRoot = folder.FullName == root.FullName; @@ -214,7 +216,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning // find mods in subfolders if (this.IsModSearchFolder(root, folder)) { - IEnumerable subfolders = folder.EnumerateDirectories().SelectMany(sub => this.GetModFolders(root, sub)); + IEnumerable subfolders = folder.EnumerateDirectories().SelectMany(sub => this.GetModFolders(root, sub, useCaseInsensitiveFilePaths)); if (!isRoot) subfolders = this.TryConsolidate(root, folder, subfolders.ToArray()); foreach (ModFolder subfolder in subfolders) -- cgit