提交 40988f7e 编写于 作者: J jp9000

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.
上级 dd9107db
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册