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.

65 lines
2.2KB

  1. /*
  2. * Carla DSSI utils
  3. * Copyright (C) 2013-2017 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 "water/files/File.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 water;
  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=File(pluginDir).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, false); --i >= 0;)
  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. // --------------------------------------------------------------------------------------------------------------------