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.

61 lines
2.2KB

  1. // SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "CarlaDssiUtils.hpp"
  4. #include "water/files/File.h"
  5. // --------------------------------------------------------------------------------------------------------------------
  6. const char* find_dssi_ui(const char* const filename, const char* const label) noexcept
  7. {
  8. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr);
  9. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', nullptr);
  10. carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename, label);
  11. try {
  12. water::String guiFilename;
  13. water::String pluginDir(water::String(filename).upToLastOccurrenceOf(".", false, false));
  14. water::String checkLabel(label);
  15. water::String checkSName(water::File(pluginDir.toRawUTF8()).getFileName());
  16. if (checkSName.endsWithIgnoreCase("dssi"))
  17. {
  18. checkSName = checkSName.dropLastCharacters(4);
  19. if (checkSName.endsWithChar('-'))
  20. checkSName = checkSName.dropLastCharacters(1);
  21. }
  22. if (! checkLabel.endsWithChar('_')) checkLabel += "_";
  23. if (! checkSName.endsWithChar('_')) checkSName += "_";
  24. std::vector<water::File> results;
  25. if (const uint count = water::File(pluginDir.toRawUTF8()).findChildFiles(
  26. results, water::File::findFiles|water::File::ignoreHiddenFiles, false))
  27. {
  28. for (uint i=0; i<count; ++i)
  29. {
  30. const water::File& gui(results[i]);
  31. const water::String& guiShortName(gui.getFileName());
  32. if (guiShortName.startsWith(checkLabel) || guiShortName.startsWith(checkSName))
  33. {
  34. guiFilename = gui.getFullPathName();
  35. break;
  36. }
  37. }
  38. }
  39. if (guiFilename.isEmpty())
  40. return nullptr;
  41. return carla_strdup(guiFilename.toRawUTF8());
  42. } CARLA_SAFE_EXCEPTION_RETURN("find_dssi_ui", nullptr);
  43. }
  44. // --------------------------------------------------------------------------------------------------------------------