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.5KB

8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Carla DSSI utils
  3. * Copyright (C) 2013-2018 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 (checkSName.endsWithIgnoreCase("dssi"))
  32. {
  33. checkSName = checkSName.dropLastCharacters(4);
  34. if (checkSName.endsWithChar('-'))
  35. checkSName = checkSName.dropLastCharacters(1);
  36. }
  37. if (! checkLabel.endsWithChar('_')) checkLabel += "_";
  38. if (! checkSName.endsWithChar('_')) checkSName += "_";
  39. Array<File> results;
  40. for (int i=File(pluginDir).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, false); --i >= 0;)
  41. {
  42. const File& gui(results[i]);
  43. const String& guiShortName(gui.getFileName());
  44. if (guiShortName.startsWith(checkLabel) || guiShortName.startsWith(checkSName))
  45. {
  46. guiFilename = gui.getFullPathName();
  47. break;
  48. }
  49. }
  50. if (guiFilename.isEmpty())
  51. return nullptr;
  52. return carla_strdup(guiFilename.toRawUTF8());
  53. } CARLA_SAFE_EXCEPTION_RETURN("find_dssi_ui", nullptr);
  54. }
  55. // --------------------------------------------------------------------------------------------------------------------