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.

68 lines
2.1KB

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