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

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