clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 16a4acec0444267e2bd883cc0608d99053712676
parent 55a509506a3063f3de003b5939ffca1ec8bf45d6
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sun,  1 Aug 2021 18:21:36 +0200

Basic path provider

Diffstat:
Mexamples/plugins/path-provider.cc | 40++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+), 0 deletions(-)

diff --git a/examples/plugins/path-provider.cc b/examples/plugins/path-provider.cc @@ -0,0 +1,39 @@ +#include <cassert> +#include <cstring> +#include <regex> +#include <filesystem> + +#include "path-provider.hh" + +namespace clap { + + class LinuxPathProvider final : public PathProvider { + public: + LinuxPathProvider(const std::string &pluginPath) : prefix_(computePrefix(pluginPath)) {} + + static std::string computePrefix(const std::string &pluginPath) { + static const std::regex r("(/.*)/lib/clap/.*$", std::regex::optimize); + + std::smatch m; + if (!std::regex_match(pluginPath, m, r)) + return "/usr"; + return m[1]; + } + + std::string getGuiExecutable() const override { return prefix_ / "/bin/clap-gui"; } + + private: + const std::filesystem::path prefix_; + }; + + const PathProvider *PathProvider::createInstance(const std::string &pluginPath) { + assert(!instance_); + +#ifdef __linux__ + return new LinuxPathProvider(pluginPath); +#endif + + // TODO + return nullptr; + } +} // namespace clap +\ No newline at end of file