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

8 years ago
8 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. water::String guiFilename;
  27. water::String pluginDir(water::String(filename).upToLastOccurrenceOf(".", false, false));
  28. water::String checkLabel(label);
  29. water::String checkSName(water::File(pluginDir).getFileName());
  30. if (checkSName.endsWithIgnoreCase("dssi"))
  31. {
  32. checkSName = checkSName.dropLastCharacters(4);
  33. if (checkSName.endsWithChar('-'))
  34. checkSName = checkSName.dropLastCharacters(1);
  35. }
  36. if (! checkLabel.endsWithChar('_')) checkLabel += "_";
  37. if (! checkSName.endsWithChar('_')) checkSName += "_";
  38. water::Array<water::File> results;
  39. for (int i=water::File(pluginDir).findChildFiles(results,
  40. water::File::findFiles|water::File::ignoreHiddenFiles, false); --i >= 0;)
  41. {
  42. const water::File& gui(results[i]);
  43. const water::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. // --------------------------------------------------------------------------------------------------------------------