libobs: Add obs_data_save_json function
We keep having to repeat code for saving the json data to a file, so add a helper function to help clean up some of that code.
This commit is contained in:
parent
dd9107dbd8
commit
40988f7e1d
@ -699,6 +699,18 @@ const char *obs_data_get_json(obs_data_t *data)
|
||||
return data->json;
|
||||
}
|
||||
|
||||
bool obs_data_save_json(obs_data_t *data, const char *file)
|
||||
{
|
||||
const char *json = obs_data_get_json(data);
|
||||
|
||||
if (json && *json) {
|
||||
return os_quick_write_utf8_file(file, json, strlen(json),
|
||||
false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct obs_data_item *get_item(struct obs_data *data, const char *name)
|
||||
{
|
||||
if (!data) return NULL;
|
||||
|
@ -67,6 +67,7 @@ EXPORT void obs_data_addref(obs_data_t *data);
|
||||
EXPORT void obs_data_release(obs_data_t *data);
|
||||
|
||||
EXPORT const char *obs_data_get_json(obs_data_t *data);
|
||||
EXPORT bool obs_data_save_json(obs_data_t *data, const char *file);
|
||||
|
||||
EXPORT void obs_data_apply(obs_data_t *target, obs_data_t *apply_data);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user