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.

CarlaDssiUtils.cpp 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Carla DSSI utils
  3. * Copyright (C) 2013-2014 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. #include "CarlaDssiUtils.hpp"
  18. #include "juce_core/juce_core.h"
  19. // -----------------------------------------------------------------------
  20. const char* find_dssi_ui(const char* const filename, const char* const label) noexcept
  21. {
  22. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr);
  23. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', nullptr);
  24. carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename, label);
  25. try {
  26. using namespace juce;
  27. String guiFilename;
  28. String pluginDir(String(filename).upToLastOccurrenceOf(".", false, false));
  29. String checkLabel(label);
  30. String checkSName(File(pluginDir).getFileName());
  31. if (! checkLabel.endsWith("_")) checkLabel += "_";
  32. if (! checkSName.endsWith("_")) checkSName += "_";
  33. Array<File> results;
  34. for (int i=0, count=File(pluginDir).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, false); i < count; ++i)
  35. {
  36. const File& gui(results[i]);
  37. const String& guiShortName(gui.getFileName());
  38. if (guiShortName.startsWith(checkLabel) || guiShortName.startsWith(checkSName))
  39. {
  40. guiFilename = gui.getFullPathName();
  41. break;
  42. }
  43. }
  44. if (guiFilename.isEmpty())
  45. return nullptr;
  46. return carla_strdup(guiFilename.toRawUTF8());
  47. } CARLA_SAFE_EXCEPTION_RETURN("find_dssi_ui", nullptr);
  48. }
  49. // -----------------------------------------------------------------------