LMMS
Loading...
Searching...
No Matches
juce_PluginDirectoryScanner.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
30{
31 StringArray lines;
32 file.readLines (lines);
33 lines.removeEmptyStrings();
34 return lines;
35}
36
38 AudioPluginFormat& formatToLookFor,
39 FileSearchPath directoriesToSearch,
40 const bool recursive,
41 const File& deadMansPedal,
42 bool allowPluginsWhichRequireAsynchronousInstantiation)
43 : list (listToAddTo),
44 format (formatToLookFor),
45 deadMansPedalFile (deadMansPedal),
46 allowAsync (allowPluginsWhichRequireAsynchronousInstantiation)
47{
48 directoriesToSearch.removeRedundantPaths();
49 setFilesOrIdentifiersToScan (format.searchPathsForPlugins (directoriesToSearch, recursive, allowAsync));
50}
51
56
57//==============================================================================
59{
60 filesOrIdentifiersToScan = filesOrIdentifiers;
61
62 // If any plugins have crashed recently when being loaded, move them to the
63 // end of the list to give the others a chance to load correctly..
64 for (auto& crashed : readDeadMansPedalFile (deadMansPedalFile))
65 for (int j = filesOrIdentifiersToScan.size(); --j >= 0;)
66 if (crashed == filesOrIdentifiersToScan[j])
67 filesOrIdentifiersToScan.move (j, -1);
68
71}
72
74{
75 return format.getNameOfPluginFromIdentifier (filesOrIdentifiersToScan [nextIndex.get() - 1]);
76}
77
79{
80 progress = (1.0f - (float) nextIndex.get() / (float) filesOrIdentifiersToScan.size());
81}
82
83bool PluginDirectoryScanner::scanNextFile (bool dontRescanIfAlreadyInList,
84 String& nameOfPluginBeingScanned)
85{
86 const int index = --nextIndex;
87
88 if (index >= 0)
89 {
90 auto file = filesOrIdentifiersToScan [index];
91
92 if (file.isNotEmpty() && ! (dontRescanIfAlreadyInList && list.isListingUpToDate (file, format)))
93 {
94 nameOfPluginBeingScanned = format.getNameOfPluginFromIdentifier (file);
95
97
98 // Add this plugin to the end of the dead-man's pedal list in case it crashes...
99 auto crashedPlugins = readDeadMansPedalFile (deadMansPedalFile);
100 crashedPlugins.removeString (file);
101 crashedPlugins.add (file);
102 setDeadMansPedalFile (crashedPlugins);
103
104 list.scanAndAddFile (file, dontRescanIfAlreadyInList, typesFound, format);
105
106 // Managed to load without crashing, so remove it from the dead-man's-pedal..
107 crashedPlugins.removeString (file);
108 setDeadMansPedalFile (crashedPlugins);
109
110 if (typesFound.size() == 0 && ! list.getBlacklistedFiles().contains (file))
111 failedFiles.add (file);
112 }
113 }
114
116 return index > 0;
117}
118
120{
122 return --nextIndex > 0;
123}
124
126{
127 if (deadMansPedalFile.getFullPathName().isNotEmpty())
128 deadMansPedalFile.replaceWithText (newContents.joinIntoString ("\n"), true, true);
129}
130
132{
133 // If any plugins have crashed recently when being loaded, move them to the
134 // end of the list to give the others a chance to load correctly..
135 for (auto& crashedPlugin : readDeadMansPedalFile (file))
136 list.addToBlacklist (crashedPlugin);
137}
138
139} // namespace juce
Definition juce_AudioPluginFormat.h:38
Definition juce_File.h:45
Definition juce_FileSearchPath.h:35
void removeRedundantPaths()
Definition juce_FileSearchPath.cpp:106
Definition juce_KnownPluginList.h:41
Definition juce_OwnedArray.h:51
int size() const noexcept
Definition juce_OwnedArray.h:130
const bool allowAsync
Definition juce_PluginDirectoryScanner.h:130
StringArray filesOrIdentifiersToScan
Definition juce_PluginDirectoryScanner.h:125
static void applyBlacklistingsFromDeadMansPedal(KnownPluginList &listToApplyTo, const File &deadMansPedalFile)
Definition juce_PluginDirectoryScanner.cpp:131
PluginDirectoryScanner(KnownPluginList &listToAddResultsTo, AudioPluginFormat &formatToLookFor, FileSearchPath directoriesToSearch, bool searchRecursively, const File &deadMansPedalFile, bool allowPluginsWhichRequireAsynchronousInstantiation=false)
Definition juce_PluginDirectoryScanner.cpp:37
bool skipNextFile()
Definition juce_PluginDirectoryScanner.cpp:119
~PluginDirectoryScanner()
Definition juce_PluginDirectoryScanner.cpp:52
String getNextPluginFileThatWillBeScanned() const
Definition juce_PluginDirectoryScanner.cpp:73
std::atomic< float > progress
Definition juce_PluginDirectoryScanner.h:129
StringArray failedFiles
Definition juce_PluginDirectoryScanner.h:127
File deadMansPedalFile
Definition juce_PluginDirectoryScanner.h:126
void setDeadMansPedalFile(const StringArray &newContents)
Definition juce_PluginDirectoryScanner.cpp:125
AudioPluginFormat & format
Definition juce_PluginDirectoryScanner.h:124
void updateProgress()
Definition juce_PluginDirectoryScanner.cpp:78
Atomic< int > nextIndex
Definition juce_PluginDirectoryScanner.h:128
bool scanNextFile(bool dontRescanIfAlreadyInList, String &nameOfPluginBeingScanned)
Definition juce_PluginDirectoryScanner.cpp:83
KnownPluginList & list
Definition juce_PluginDirectoryScanner.h:123
void setFilesOrIdentifiersToScan(const StringArray &filesOrIdentifiersToScan)
Definition juce_PluginDirectoryScanner.cpp:58
Definition juce_StringArray.h:35
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Definition juce_StringArray.cpp:289
void removeEmptyStrings(bool removeWhitespaceStrings=true)
Definition juce_StringArray.cpp:250
Definition juce_String.h:53
register unsigned j
Definition inflate.c:1576
Definition carla_juce.cpp:31
static StringArray readDeadMansPedalFile(const File &file)
Definition juce_PluginDirectoryScanner.cpp:29
struct zdirent * file
Definition win32.c:1500