ignore more content file types when detecting mods
This commit is contained in:
parent
4590b75bc3
commit
4b07e10520
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
## Upcoming release
|
## Upcoming release
|
||||||
* For players:
|
* For players:
|
||||||
|
* SMAPI now ignores more content file types when detecting mods (`.doc`, `.docx`, `.rar`, and `.zip`).
|
||||||
* Fixed launcher's fallback logic on Linux when no compatible terminal was found (thanks to jlaw!).
|
* Fixed launcher's fallback logic on Linux when no compatible terminal was found (thanks to jlaw!).
|
||||||
|
|
||||||
* For the Console Commands mod:
|
* For the Console Commands mod:
|
||||||
|
|
|
@ -18,18 +18,44 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
|
||||||
private readonly JsonHelper JsonHelper;
|
private readonly JsonHelper JsonHelper;
|
||||||
|
|
||||||
/// <summary>A list of filesystem entry names to ignore when checking whether a folder should be treated as a mod.</summary>
|
/// <summary>A list of filesystem entry names to ignore when checking whether a folder should be treated as a mod.</summary>
|
||||||
private readonly HashSet<Regex> IgnoreFilesystemEntries = new HashSet<Regex>
|
private readonly HashSet<Regex> IgnoreFilesystemNames = new HashSet<Regex>
|
||||||
{
|
{
|
||||||
// OS metadata files
|
|
||||||
new Regex(@"^__folder_managed_by_vortex$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Vortex mod manager
|
new Regex(@"^__folder_managed_by_vortex$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Vortex mod manager
|
||||||
new Regex(@"(?:^\._|^\.DS_Store$|^__MACOSX$|^mcs$)", RegexOptions.Compiled | RegexOptions.IgnoreCase), // MacOS
|
new Regex(@"(?:^\._|^\.DS_Store$|^__MACOSX$|^mcs$)", RegexOptions.Compiled | RegexOptions.IgnoreCase), // MacOS
|
||||||
new Regex(@"^(?:desktop\.ini|Thumbs\.db)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Windows
|
new Regex(@"^(?:desktop\.ini|Thumbs\.db)$", RegexOptions.Compiled | RegexOptions.IgnoreCase) // Windows
|
||||||
new Regex(@"\.(?:url|lnk)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Windows shortcut files
|
};
|
||||||
|
|
||||||
// other
|
/// <summary>A list of file extensions to ignore when searching for mod files.</summary>
|
||||||
new Regex(@"\.(?:bmp|gif|jpeg|jpg|png|psd|tif)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // image files
|
private readonly HashSet<string> IgnoreFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
new Regex(@"\.(?:md|rtf|txt)$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // text files
|
{
|
||||||
new Regex(@"\.(?:backup|bak|old)$", RegexOptions.Compiled | RegexOptions.IgnoreCase) // backup file
|
// text
|
||||||
|
".doc",
|
||||||
|
".docx",
|
||||||
|
".md",
|
||||||
|
".rtf",
|
||||||
|
".txt",
|
||||||
|
|
||||||
|
// images
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".jpeg",
|
||||||
|
".jpg",
|
||||||
|
".png",
|
||||||
|
".psd",
|
||||||
|
".tif",
|
||||||
|
|
||||||
|
// archives
|
||||||
|
".rar",
|
||||||
|
".zip",
|
||||||
|
|
||||||
|
// backup files
|
||||||
|
".backup",
|
||||||
|
".bak",
|
||||||
|
".old",
|
||||||
|
|
||||||
|
// Windows shortcut files
|
||||||
|
".url",
|
||||||
|
".lnk"
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>The extensions for files which an XNB mod may contain. If a mod doesn't have a <c>manifest.json</c> and contains *only* these file extensions, it should be considered an XNB mod.</summary>
|
/// <summary>The extensions for files which an XNB mod may contain. If a mod doesn't have a <c>manifest.json</c> and contains *only* these file extensions, it should be considered an XNB mod.</summary>
|
||||||
|
@ -258,7 +284,12 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
|
||||||
/// <param name="entry">The file or folder.</param>
|
/// <param name="entry">The file or folder.</param>
|
||||||
private bool IsRelevant(FileSystemInfo entry)
|
private bool IsRelevant(FileSystemInfo entry)
|
||||||
{
|
{
|
||||||
return !this.IgnoreFilesystemEntries.Any(p => p.IsMatch(entry.Name));
|
// ignored file extension
|
||||||
|
if (entry is FileInfo file && this.IgnoreFileExtensions.Contains(file.Extension))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// ignored entry name
|
||||||
|
return !this.IgnoreFilesystemNames.Any(p => p.IsMatch(entry.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get whether a file is potentially part of an XNB mod.</summary>
|
/// <summary>Get whether a file is potentially part of an XNB mod.</summary>
|
||||||
|
|
Loading…
Reference in New Issue