The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
5.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_PLUGINDIRECTORYSCANNER_JUCEHEADER__
  19. #define __JUCE_PLUGINDIRECTORYSCANNER_JUCEHEADER__
  20. #include "juce_KnownPluginList.h"
  21. #include "../format/juce_AudioPluginFormatManager.h"
  22. //==============================================================================
  23. /**
  24. Scans a directory for plugins, and adds them to a KnownPluginList.
  25. To use one of these, create it and call scanNextFile() repeatedly, until
  26. it returns false.
  27. */
  28. class JUCE_API PluginDirectoryScanner
  29. {
  30. public:
  31. //==============================================================================
  32. /**
  33. Creates a scanner.
  34. @param listToAddResultsTo this will get the new types added to it.
  35. @param formatToLookFor this is the type of format that you want to look for
  36. @param directoriesToSearch the path to search
  37. @param searchRecursively true to search recursively
  38. @param deadMansPedalFile if this isn't File::nonexistent, then it will
  39. be used as a file to store the names of any plugins
  40. that crash during initialisation. If there are
  41. any plugins listed in it, then these will always
  42. be scanned after all other possible files have
  43. been tried - in this way, even if there's a few
  44. dodgy plugins in your path, then a couple of rescans
  45. will still manage to find all the proper plugins.
  46. It's probably best to choose a file in the user's
  47. application data directory (alongside your app's
  48. settings file) for this. The file format it uses
  49. is just a list of filenames of the modules that
  50. failed.
  51. */
  52. PluginDirectoryScanner (KnownPluginList& listToAddResultsTo,
  53. AudioPluginFormat& formatToLookFor,
  54. FileSearchPath directoriesToSearch,
  55. bool searchRecursively,
  56. const File& deadMansPedalFile);
  57. /** Destructor. */
  58. ~PluginDirectoryScanner();
  59. //==============================================================================
  60. /** Tries the next likely-looking file.
  61. If dontRescanIfAlreadyInList is true, then the file will only be loaded and
  62. re-tested if it's not already in the list, or if the file's modification
  63. time has changed since the list was created. If dontRescanIfAlreadyInList is
  64. false, the file will always be reloaded and tested.
  65. Returns false when there are no more files to try.
  66. */
  67. bool scanNextFile (bool dontRescanIfAlreadyInList);
  68. /** Skips over the next file without scanning it.
  69. Returns false when there are no more files to try.
  70. */
  71. bool skipNextFile();
  72. /** Returns the description of the plugin that will be scanned during the next
  73. call to scanNextFile().
  74. This is handy if you want to show the user which file is currently getting
  75. scanned.
  76. */
  77. const String getNextPluginFileThatWillBeScanned() const;
  78. /** Returns the estimated progress, between 0 and 1.
  79. */
  80. float getProgress() const { return progress; }
  81. /** This returns a list of all the filenames of things that looked like being
  82. a plugin file, but which failed to open for some reason.
  83. */
  84. const StringArray& getFailedFiles() const noexcept { return failedFiles; }
  85. private:
  86. //==============================================================================
  87. KnownPluginList& list;
  88. AudioPluginFormat& format;
  89. StringArray filesOrIdentifiersToScan;
  90. File deadMansPedalFile;
  91. StringArray failedFiles;
  92. int nextIndex;
  93. float progress;
  94. StringArray getDeadMansPedalFile();
  95. void setDeadMansPedalFile (const StringArray& newContents);
  96. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginDirectoryScanner);
  97. };
  98. #endif // __JUCE_PLUGINDIRECTORYSCANNER_JUCEHEADER__