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.

76 lines
2.4KB

  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. carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename, label);
  29. using namespace juce;
  30. File pluginFile(filename);
  31. File pluginDir(pluginFile.getParentDirectory().getFullPathName() + File::separatorString + pluginFile.getFileNameWithoutExtension());
  32. Array<File> results;
  33. if (pluginDir.findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, false) == 0)
  34. return nullptr;
  35. StringArray guiFiles;
  36. for (int i=0, count=results.size(); i < count; ++i)
  37. {
  38. const File& file(results[i]);
  39. guiFiles.add(file.getFileName());
  40. }
  41. String pluginDirName(pluginDir.getFullPathName());
  42. String pluginShortName(pluginFile.getFileNameWithoutExtension());
  43. String checkLabel(label);
  44. String checkShort(pluginShortName);
  45. if (! checkLabel.endsWith("_")) checkLabel += "_";
  46. if (! checkShort.endsWith("_")) checkShort += "_";
  47. for (int i=0, count=guiFiles.size(); i < count; ++i)
  48. {
  49. const String& gui(guiFiles[i]);
  50. if (gui.startsWith(checkLabel) || gui.startsWith(checkShort))
  51. return carla_strdup(File(pluginDir).getChildFile(gui).getFullPathName().toRawUTF8());
  52. }
  53. return nullptr;
  54. }
  55. // -----------------------------------------------------------------------
  56. #endif // CARLA_DSSI_UTILS_HPP_INCLUDED