diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index fac7cca8be..72f1014e95 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -902,9 +902,32 @@ void config_set_bool(config_file_t *conf, const char *key, bool val) config_set_string(conf, key, val ? "true" : "false"); } -/* Dump the current config to an already opened file. - * Does not close the file. */ -static void config_file_dump(config_file_t *conf, FILE *file) +bool config_file_write(config_file_t *conf, const char *path) +{ + if (!string_is_empty(path)) + { + void* buf = NULL; + FILE *file = fopen_utf8(path, "wb"); + if (!file) + return false; + + /* TODO: this is only useful for a few platforms, find which and add ifdef */ + buf = calloc(1, 0x4000); + setvbuf(file, (char*)buf, _IOFBF, 0x4000); + + config_file_dump(conf, file); + + if (file != stdout) + fclose(file); + free(buf); + } + else + config_file_dump(conf, stdout); + + return true; +} + +void config_file_dump(config_file_t *conf, FILE *file) { struct config_entry_list *list = NULL; struct config_include_list *includes = conf->includes; @@ -925,33 +948,6 @@ static void config_file_dump(config_file_t *conf, FILE *file) } } -bool config_file_write(config_file_t *conf, const char *path) -{ - void* buf = NULL; - FILE *file = !string_is_empty(path) ? fopen_utf8(path, "wb") : stdout; - - if (!file) - return false; - - /* TODO: this is only useful for a few platforms, find which and add ifdef */ - if (file != stdout) - { - buf = calloc(1, 0x4000); - setvbuf(file, (char*)buf, _IOFBF, 0x4000); - } - - config_file_dump(conf, file); - - if (file != stdout) - { - fclose(file); - free(buf); - } - - return true; -} - - bool config_entry_exists(config_file_t *conf, const char *entry) { struct config_entry_list *list = conf->entries; diff --git a/libretro-common/include/file/config_file.h b/libretro-common/include/file/config_file.h index 2cbe46b41d..9a19beda4e 100644 --- a/libretro-common/include/file/config_file.h +++ b/libretro-common/include/file/config_file.h @@ -154,6 +154,10 @@ void config_set_bool(config_file_t *conf, const char *entry, bool val); /* Write the current config to a file. */ bool config_file_write(config_file_t *conf, const char *path); +/* Dump the current config to an already opened file. + * Does not close the file. */ +void config_file_dump(config_file_t *conf, FILE *file); + bool config_file_exists(const char *path); RETRO_END_DECLS