mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-14 00:14:18 +00:00
Projucer: Remove recursion from module path checks and cache previous module directories
This commit is contained in:
parent
666d9d1ed4
commit
78368cfe1a
2 changed files with 26 additions and 12 deletions
|
|
@ -163,6 +163,7 @@ bool ModuleList::tryToAddModuleFromFolder (const File& path)
|
|||
|
||||
if (m.isValid())
|
||||
{
|
||||
getPreviousModuleDirectories().addIfNotAlreadyThere (path.getParentDirectory());
|
||||
modules.add (new ModuleDescription (m));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -174,23 +175,27 @@ void ModuleList::addAllModulesInFolder (const File& path)
|
|||
{
|
||||
if (! tryToAddModuleFromFolder (path))
|
||||
{
|
||||
int subfolders = 3;
|
||||
addAllModulesInSubfoldersRecursively (path, subfolders);
|
||||
for (DirectoryIterator iter (path, false, "*", File::findDirectories); iter.next();)
|
||||
tryToAddModuleFromFolder (iter.getFile().getLinkedTarget());
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleList::addAllModulesInSubfoldersRecursively (const File& path, int depth)
|
||||
Array<File>& ModuleList::getPreviousModuleDirectories()
|
||||
{
|
||||
if (depth > 0)
|
||||
{
|
||||
for (DirectoryIterator iter (path, false, "*", File::findDirectories); iter.next();)
|
||||
{
|
||||
auto childPath = iter.getFile().getLinkedTarget();
|
||||
static Array<File> previous;
|
||||
return previous;
|
||||
}
|
||||
|
||||
if (! tryToAddModuleFromFolder (childPath))
|
||||
addAllModulesInSubfoldersRecursively (childPath, depth - 1);
|
||||
}
|
||||
File ModuleList::tryToFindModulePathFromPrevious (const String& id)
|
||||
{
|
||||
for (auto& f : getPreviousModuleDirectories())
|
||||
{
|
||||
auto modulePath = f.getChildFile (id);
|
||||
if (ModuleDescription (modulePath).isValid())
|
||||
return modulePath;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -683,6 +688,13 @@ File EnabledModuleList::findFolderForModule (const String& moduleID)
|
|||
if (isJUCEModule (moduleID))
|
||||
return File (getAppSettings().getStoredPath (Ids::defaultJuceModulePath).toString()).getChildFile (moduleID);
|
||||
|
||||
{
|
||||
auto previous = ModuleList::tryToFindModulePathFromPrevious (moduleID);
|
||||
|
||||
if (previous != File())
|
||||
return previous;
|
||||
}
|
||||
|
||||
ModuleList list;
|
||||
list.scanGlobalUserModulePath();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue