From 38161f63a3779e7945927baac2a30f3cbfa1353e Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Tue, 1 Jun 2021 21:09:53 +0200 Subject: [PATCH] Add helper getDataFilePath() Used to get absolute file path to files in the plugin's data directory --- src/headers/utility.hpp | 2 ++ src/utility.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/headers/utility.hpp b/src/headers/utility.hpp index c6f2b4c3..2a461120 100644 --- a/src/headers/utility.hpp +++ b/src/headers/utility.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "scene-group.hpp" bool WeakSourceValid(obs_weak_source_t *ws); @@ -22,6 +23,7 @@ OBSWeakSource GetWeakFilterByName(OBSWeakSource source, const char *name); OBSWeakSource GetWeakFilterByQString(OBSWeakSource source, const QString &name); bool compareIgnoringLineEnding(QString &s1, QString &s2); std::string getSourceSettings(OBSWeakSource ws); +std::filesystem::path getDataFilePath(const std::string &file); /** * Populate layout with labels and widgets based on provided text diff --git a/src/utility.cpp b/src/utility.cpp index 7a94d3da..1f2283d2 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -218,6 +218,17 @@ std::string getSourceSettings(OBSWeakSource ws) return settings; } +std::filesystem::path getDataFilePath(const std::string &file) +{ + const char *root_path = obs_get_module_data_path(obs_current_module()); + if (root_path) { + auto ret = std::filesystem::u8path(root_path); + ret.append(file.data()); + return ret; + } + return ""; +} + bool DisplayMessage(const QString &msg, bool question) { if (question) {