diff --git a/source/plugin.cpp b/source/plugin.cpp index 1d1b265c..5e92deee 100644 --- a/source/plugin.cpp +++ b/source/plugin.cpp @@ -270,3 +270,27 @@ void streamfx::gs_draw_fullscreen_tri() gs_load_vertexbuffer(_gs_fstri_vb->update(false)); gs_draw(GS_TRIS, 0, 3); //_gs_fstri_vb->size()); } + +std::filesystem::path streamfx::data_file_path(std::string_view 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; + } else { + throw std::runtime_error("obs_get_module_data_path returned nullptr"); + } +} + +std::filesystem::path streamfx::config_file_path(std::string_view file) +{ + char* root_path = obs_module_get_config_path(obs_current_module(), file.data()); + if (root_path) { + auto ret = std::filesystem::u8path(root_path); + bfree(root_path); + return ret; + } else { + throw std::runtime_error("obs_module_get_config_path returned nullptr"); + } +} diff --git a/source/plugin.hpp b/source/plugin.hpp index a0dcbbfa..48797d17 100644 --- a/source/plugin.hpp +++ b/source/plugin.hpp @@ -25,4 +25,7 @@ namespace streamfx { std::shared_ptr threadpool(); void gs_draw_fullscreen_tri(); + + std::filesystem::path data_file_path(std::string_view file); + std::filesystem::path config_file_path(std::string_view file); } // namespace streamfx