Skip to content

Commit

Permalink
Fixed an issue with Extended Folder Scanning not running without stri…
Browse files Browse the repository at this point in the history
…ct definition of Folder Names
  • Loading branch information
HerpDerpinstine committed Dec 8, 2024
1 parent 91d56f3 commit e5a3b9f
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions MelonLoader/Melons/MelonFolderHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,36 @@ private static void FindMelonFolders(
}
}

private static void ScanExtraFolders(eScanType scanType,
string path,
ref List<string> userLibDirectories,
ref List<string> pluginDirectories,
ref List<string> modDirectories)
{
string[] directories = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);
if ((directories == null)
|| (directories.Length <= 0))
return;

foreach (var dir in directories)
{
if (userLibDirectories.Contains(dir)
|| pluginDirectories.Contains(dir)
|| modDirectories.Contains(dir))
continue;

ScanExtraFolders(scanType, dir, ref userLibDirectories, ref pluginDirectories, ref modDirectories);

// Add to Directories List
if (scanType == eScanType.UserLibs)
userLibDirectories.Add(dir);
else if (scanType == eScanType.Plugins)
pluginDirectories.Add(dir);
else
modDirectories.Add(dir);
}
}

private static void ScanFolder(eScanType scanType,
string path,
ref List<string> userLibDirectories,
Expand Down Expand Up @@ -193,20 +223,22 @@ private static void ScanFolder(eScanType scanType,

// Is UserLibs Scan?
if (scanType == eScanType.UserLibs)
{
ScanExtraFolders(scanType, dir, ref userLibDirectories, ref pluginDirectories, ref modDirectories);
userLibDirectories.Add(dir); // Add to Directories List
}
else
{
// Check for Deeper Melon Folder
string melonPath = Path.Combine(dir, "Plugins");
if (Directory.Exists(melonPath))
{
pluginDirectories.Add(melonPath);
ScanFolder(scanType, melonPath, ref userLibDirectories, ref pluginDirectories, ref modDirectories);
ScanFolder(eScanType.Plugins, melonPath, ref userLibDirectories, ref pluginDirectories, ref modDirectories);
}

if (scanType == eScanType.Mods)
{
// Check for Deeper Melon Folder
melonPath = Path.Combine(dir, "Mods");
if (Directory.Exists(melonPath))
{
Expand All @@ -215,6 +247,8 @@ private static void ScanFolder(eScanType scanType,
}
}

ScanExtraFolders(scanType, dir, ref userLibDirectories, ref pluginDirectories, ref modDirectories);

// Add to Directories List
if (scanType == eScanType.Mods)
modDirectories.Add(dir);
Expand Down

0 comments on commit e5a3b9f

Please sign in to comment.