1 // SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
2 // SPDX-License-Identifier: GPL-2.0-or-later
4 #include "CarlaDssiUtils.hpp"
6 #include "water/files/File.h"
8 // --------------------------------------------------------------------------------------------------------------------
10 const char* find_dssi_ui(const char* const filename
, const char* const label
) noexcept
12 CARLA_SAFE_ASSERT_RETURN(filename
!= nullptr && filename
[0] != '\0', nullptr);
13 CARLA_SAFE_ASSERT_RETURN(label
!= nullptr && label
[0] != '\0', nullptr);
14 carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename
, label
);
17 water::String guiFilename
;
18 water::String
pluginDir(water::String(filename
).upToLastOccurrenceOf(".", false, false));
20 water::String
checkLabel(label
);
21 water::String
checkSName(water::File(pluginDir
.toRawUTF8()).getFileName());
23 if (checkSName
.endsWithIgnoreCase("dssi"))
25 checkSName
= checkSName
.dropLastCharacters(4);
27 if (checkSName
.endsWithChar('-'))
28 checkSName
= checkSName
.dropLastCharacters(1);
31 if (! checkLabel
.endsWithChar('_')) checkLabel
+= "_";
32 if (! checkSName
.endsWithChar('_')) checkSName
+= "_";
34 std::vector
<water::File
> results
;
36 if (const uint count
= water::File(pluginDir
.toRawUTF8()).findChildFiles(
37 results
, water::File::findFiles
|water::File::ignoreHiddenFiles
, false))
39 for (uint i
=0; i
<count
; ++i
)
41 const water::File
& gui(results
[i
]);
42 const water::String
& guiShortName(gui
.getFileName());
44 if (guiShortName
.startsWith(checkLabel
) || guiShortName
.startsWith(checkSName
))
46 guiFilename
= gui
.getFullPathName();
52 if (guiFilename
.isEmpty())
55 return carla_strdup(guiFilename
.toRawUTF8());
57 } CARLA_SAFE_EXCEPTION_RETURN("find_dssi_ui", nullptr);
60 // --------------------------------------------------------------------------------------------------------------------