mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
plugin: Implement proper functions to get config and data files
Using the obs_module_file and obs_module_config_path macros works okay, but it comes with a slight overhead as well as additional requirements when passing it to C++ functions that expect certain rules to be fulfilled. By instead wrapping the actual functionality into our own functions and using those we can avoid most of the issues that come with the old approach. Related: #359
This commit is contained in:
parent
7be1929985
commit
4de094511a
2 changed files with 27 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,4 +25,7 @@ namespace streamfx {
|
|||
std::shared_ptr<util::threadpool> 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
|
||||
|
|
Loading…
Reference in a new issue