libobs: Add obs_data_create_from_json_file func
Just a little helper function that allows you to create an obs_data_t object from a json file (rather than having to manually open it each time and then call obs_data_create_from_json on the file data)
This commit is contained in:
parent
1ca065b0f2
commit
d53cef47ac
@ -18,6 +18,7 @@
|
||||
#include "util/bmem.h"
|
||||
#include "util/threading.h"
|
||||
#include "util/darray.h"
|
||||
#include "util/platform.h"
|
||||
#include "graphics/vec2.h"
|
||||
#include "graphics/vec3.h"
|
||||
#include "graphics/vec4.h"
|
||||
@ -639,6 +640,19 @@ obs_data_t *obs_data_create_from_json(const char *json_string)
|
||||
return data;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_create_from_json_file(const char *json_file)
|
||||
{
|
||||
char *file_data = os_quick_read_utf8_file(json_file);
|
||||
obs_data_t *data = NULL;
|
||||
|
||||
if (file_data) {
|
||||
data = obs_data_create_from_json(file_data);
|
||||
bfree(file_data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void obs_data_addref(obs_data_t *data)
|
||||
{
|
||||
if (data)
|
||||
|
@ -62,6 +62,7 @@ enum obs_data_number_type {
|
||||
|
||||
EXPORT obs_data_t *obs_data_create();
|
||||
EXPORT obs_data_t *obs_data_create_from_json(const char *json_string);
|
||||
EXPORT obs_data_t *obs_data_create_from_json_file(const char *json_file);
|
||||
EXPORT void obs_data_addref(obs_data_t *data);
|
||||
EXPORT void obs_data_release(obs_data_t *data);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user