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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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)
  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. QString guiFilename;
  28. QString pluginDir(filename);
  29. pluginDir.resize(pluginDir.lastIndexOf("."));
  30. QString checkLabel(label);
  31. QString checkSName(QFileInfo(pluginDir).baseName());
  32. if (! checkLabel.endsWith("_")) checkLabel += "_";
  33. if (! checkSName.endsWith("_")) checkSName += "_";
  34. QStringList guiFiles(QDir(pluginDir).entryList());
  35. foreach (const QString& gui, guiFiles)
  36. {
  37. if (gui.startsWith(checkLabel) || gui.startsWith(checkSName))
  38. {
  39. QFileInfo finalname(pluginDir + QDir::separator() + gui);
  40. guiFilename = finalname.absoluteFilePath();
  41. break;
  42. }
  43. }
  44. if (guiFilename.isEmpty())
  45. return nullptr;
  46. return carla_strdup(guiFilename.toUtf8().constData());
  47. }
  48. // -----------------------------------------------------------------------