mirror of
https://github.com/libretro/RetroArch
synced 2025-04-11 00:44:20 +00:00
Revert "Simplify config_file_write"
This reverts commit a4500eeafc0b19dd9fe665059f2143d29fa01868.
This commit is contained in:
parent
63dc7cbedb
commit
f2ddc8eff0
@ -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");
|
config_set_string(conf, key, val ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dump the current config to an already opened file.
|
bool config_file_write(config_file_t *conf, const char *path)
|
||||||
* Does not close the file. */
|
{
|
||||||
static void config_file_dump(config_file_t *conf, FILE *file)
|
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_entry_list *list = NULL;
|
||||||
struct config_include_list *includes = conf->includes;
|
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)
|
bool config_entry_exists(config_file_t *conf, const char *entry)
|
||||||
{
|
{
|
||||||
struct config_entry_list *list = conf->entries;
|
struct config_entry_list *list = conf->entries;
|
||||||
|
@ -154,6 +154,10 @@ void config_set_bool(config_file_t *conf, const char *entry, bool val);
|
|||||||
/* Write the current config to a file. */
|
/* Write the current config to a file. */
|
||||||
bool config_file_write(config_file_t *conf, const char *path);
|
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);
|
bool config_file_exists(const char *path);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user