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.

64 lines
2.1KB

  1. /*
  2. * Carla DSSI utils
  3. * Copyright (C) 2013-2014 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 <QtCore/QDir>
  19. #include <QtCore/QFileInfo>
  20. #include <QtCore/QStringList>
  21. // -----------------------------------------------------------------------
  22. const char* find_dssi_ui(const char* const filename, const char* const label) noexcept
  23. {
  24. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr);
  25. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', nullptr);
  26. carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename, label);
  27. try {
  28. QString guiFilename;
  29. QString pluginDir(filename);
  30. pluginDir.resize(pluginDir.lastIndexOf("."));
  31. QString checkLabel(label);
  32. QString checkSName(QFileInfo(pluginDir).baseName());
  33. if (! checkLabel.endsWith("_")) checkLabel += "_";
  34. if (! checkSName.endsWith("_")) checkSName += "_";
  35. QStringList guiFiles(QDir(pluginDir).entryList());
  36. foreach (const QString& gui, guiFiles)
  37. {
  38. if (gui.startsWith(checkLabel) || gui.startsWith(checkSName))
  39. {
  40. QFileInfo finalname(pluginDir + QDir::separator() + gui);
  41. guiFilename = finalname.absoluteFilePath();
  42. break;
  43. }
  44. }
  45. if (guiFilename.isEmpty())
  46. return nullptr;
  47. return carla_strdup(guiFilename.toUtf8().constData());
  48. } CARLA_SAFE_EXCEPTION_RETURN("find_dssi_ui", nullptr);
  49. }
  50. // -----------------------------------------------------------------------