Audio plugin host https://kx.studio/carla
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.

75 lines
2.2KB

  1. /*
  2. * Carla DSSI utils
  3. * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_DSSI_UTILS_HPP_INCLUDED
  18. #define CARLA_DSSI_UTILS_HPP_INCLUDED
  19. #include "CarlaLadspaUtils.hpp"
  20. #include "dssi/dssi.h"
  21. #include "juce_core.h"
  22. // -----------------------------------------------------------------------
  23. static inline
  24. const char* find_dssi_ui(const char* const filename, const char* const label)
  25. {
  26. CARLA_SAFE_ASSERT_RETURN(filename != nullptr, nullptr);
  27. CARLA_SAFE_ASSERT_RETURN(label != nullptr, nullptr);
  28. using namespace juce;
  29. File pluginFile(filename);
  30. File pluginDir(pluginFile.getParentDirectory());
  31. Array<File> results;
  32. if (pluginDir.findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, false) == 0)
  33. return nullptr;
  34. StringArray guiFiles;
  35. for (int i=0, count=results.size(); i < count; ++i)
  36. {
  37. const File& file(results[i]);
  38. guiFiles.add(file.getFullPathName());
  39. }
  40. String pluginDirName(pluginDir.getFullPathName());
  41. String pluginShortName(pluginFile.getFileNameWithoutExtension());
  42. String checkLabel(label);
  43. String checkShort(pluginShortName);
  44. if (! checkLabel.endsWith("_")) checkLabel += "_";
  45. if (! checkShort.endsWith("_")) checkShort += "_";
  46. for (int i=0, count=guiFiles.size(); i < count; ++i)
  47. {
  48. const String& gui(guiFiles[i]);
  49. if (gui.startsWith(checkLabel) || gui.startsWith(checkShort))
  50. return carla_strdup(File(pluginDir).getChildFile(gui).getFullPathName().toRawUTF8());
  51. }
  52. return nullptr;
  53. }
  54. // -----------------------------------------------------------------------
  55. #endif // CARLA_DSSI_UTILS_HPP_INCLUDED