mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 16:20:39 +00:00
Merge pull request #7881 from orbea/sort
libretro-common: Sort config file conditionally.
This commit is contained in:
commit
33c777cbfc
@ -2275,7 +2275,7 @@ static config_file_t *open_default_config_file(void)
|
|||||||
fill_pathname_resolve_relative(conf_path, app_path,
|
fill_pathname_resolve_relative(conf_path, app_path,
|
||||||
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
|
||||||
config_set_bool(conf, "config_save_on_exit", true);
|
config_set_bool(conf, "config_save_on_exit", true);
|
||||||
saved = config_file_write(conf, conf_path);
|
saved = config_file_write(conf, conf_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saved)
|
if (!saved)
|
||||||
@ -2311,7 +2311,7 @@ static config_file_t *open_default_config_file(void)
|
|||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
config_set_bool(conf, "config_save_on_exit", true);
|
config_set_bool(conf, "config_save_on_exit", true);
|
||||||
saved = config_file_write(conf, conf_path);
|
saved = config_file_write(conf, conf_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saved)
|
if (!saved)
|
||||||
@ -2386,7 +2386,7 @@ static config_file_t *open_default_config_file(void)
|
|||||||
{
|
{
|
||||||
/* Since this is a clean config file, we can safely use config_save_on_exit. */
|
/* Since this is a clean config file, we can safely use config_save_on_exit. */
|
||||||
config_set_bool(conf, "config_save_on_exit", true);
|
config_set_bool(conf, "config_save_on_exit", true);
|
||||||
saved = config_file_write(conf, conf_path);
|
saved = config_file_write(conf, conf_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saved)
|
if (!saved)
|
||||||
@ -4046,7 +4046,7 @@ static bool config_save_keybinds_file(const char *path)
|
|||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
save_keybinds_user(conf, i);
|
save_keybinds_user(conf, i);
|
||||||
|
|
||||||
ret = config_file_write(conf, path);
|
ret = config_file_write(conf, path, true);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4155,7 +4155,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
|
|||||||
&input_config_binds[user][i], false, false);
|
&input_config_binds[user][i], false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = config_file_write(conf, autoconf_file);
|
ret = config_file_write(conf, autoconf_file, false);
|
||||||
|
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -4405,7 +4405,7 @@ bool config_save_file(const char *path)
|
|||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
save_keybinds_user(conf, i);
|
save_keybinds_user(conf, i);
|
||||||
|
|
||||||
ret = config_file_write(conf, path);
|
ret = config_file_write(conf, path, true);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -4677,17 +4677,17 @@ bool config_save_overrides(int override_type)
|
|||||||
case OVERRIDE_CORE:
|
case OVERRIDE_CORE:
|
||||||
/* Create a new config file from core_path */
|
/* Create a new config file from core_path */
|
||||||
RARCH_LOG ("[overrides] path %s\n", core_path);
|
RARCH_LOG ("[overrides] path %s\n", core_path);
|
||||||
ret = config_file_write(conf, core_path);
|
ret = config_file_write(conf, core_path, true);
|
||||||
break;
|
break;
|
||||||
case OVERRIDE_GAME:
|
case OVERRIDE_GAME:
|
||||||
/* Create a new config file from core_path */
|
/* Create a new config file from core_path */
|
||||||
RARCH_LOG ("[overrides] path %s\n", game_path);
|
RARCH_LOG ("[overrides] path %s\n", game_path);
|
||||||
ret = config_file_write(conf, game_path);
|
ret = config_file_write(conf, game_path, true);
|
||||||
break;
|
break;
|
||||||
case OVERRIDE_CONTENT_DIR:
|
case OVERRIDE_CONTENT_DIR:
|
||||||
/* Create a new config file from content_path */
|
/* Create a new config file from content_path */
|
||||||
RARCH_LOG ("[overrides] path %s\n", content_path);
|
RARCH_LOG ("[overrides] path %s\n", content_path);
|
||||||
ret = config_file_write(conf, content_path);
|
ret = config_file_write(conf, content_path, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -162,7 +162,7 @@ static void salamander_init(char *s, size_t len)
|
|||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
config_set_string(conf, "libretro_path", s);
|
config_set_string(conf, "libretro_path", s);
|
||||||
config_file_write(conf, g_defaults.path.config);
|
config_file_write(conf, g_defaults.path.config, true);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ bool input_remapping_save_file(const char *path)
|
|||||||
config_set_int(conf, s1, settings->uints.input_analog_dpad_mode[i]);
|
config_set_int(conf, s1, settings->uints.input_analog_dpad_mode[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = config_file_write(conf, remap_file);
|
ret = config_file_write(conf, remap_file, true);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
||||||
free(remap_file);
|
free(remap_file);
|
||||||
|
@ -976,7 +976,7 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool config_file_write(config_file_t *conf, const char *path)
|
bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||||
{
|
{
|
||||||
if (!string_is_empty(path))
|
if (!string_is_empty(path))
|
||||||
{
|
{
|
||||||
@ -991,19 +991,19 @@ bool config_file_write(config_file_t *conf, const char *path)
|
|||||||
setvbuf(file, (char*)buf, _IOFBF, 0x4000);
|
setvbuf(file, (char*)buf, _IOFBF, 0x4000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
config_file_dump(conf, file);
|
config_file_dump(conf, file, sort);
|
||||||
|
|
||||||
if (file != stdout)
|
if (file != stdout)
|
||||||
fclose(file);
|
fclose(file);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config_file_dump(conf, stdout);
|
config_file_dump(conf, stdout, sort);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_file_dump(config_file_t *conf, FILE *file)
|
void config_file_dump(config_file_t *conf, FILE *file, bool sort)
|
||||||
{
|
{
|
||||||
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;
|
||||||
@ -1014,7 +1014,11 @@ void config_file_dump(config_file_t *conf, FILE *file)
|
|||||||
includes = includes->next;
|
includes = includes->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func);
|
if (sort)
|
||||||
|
list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func);
|
||||||
|
else
|
||||||
|
list = (struct config_entry_list*)conf->entries;
|
||||||
|
|
||||||
conf->entries = list;
|
conf->entries = list;
|
||||||
|
|
||||||
while (list)
|
while (list)
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_CONFIG_FILE_H
|
#ifndef __LIBRETRO_SDK_CONFIG_FILE_H
|
||||||
#define __LIBRETRO_SDK_CONFIG_FILE_H
|
#define __LIBRETRO_SDK_CONFIG_FILE_H
|
||||||
|
|
||||||
@ -64,7 +63,6 @@ struct config_file
|
|||||||
struct config_include_list *includes;
|
struct config_include_list *includes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct config_file config_file_t;
|
typedef struct config_file config_file_t;
|
||||||
|
|
||||||
struct config_file_cb
|
struct config_file_cb
|
||||||
@ -181,15 +179,14 @@ void config_set_bool(config_file_t *conf, const char *entry, bool val);
|
|||||||
void config_set_uint(config_file_t *conf, const char *key, unsigned int val);
|
void config_set_uint(config_file_t *conf, const char *key, unsigned int 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, bool val);
|
||||||
|
|
||||||
/* Dump the current config to an already opened file.
|
/* Dump the current config to an already opened file.
|
||||||
* Does not close the file. */
|
* Does not close the file. */
|
||||||
void config_file_dump(config_file_t *conf, FILE *file);
|
void config_file_dump(config_file_t *conf, FILE *file, bool val);
|
||||||
|
|
||||||
bool config_file_exists(const char *path);
|
bool config_file_exists(const char *path);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@
|
|||||||
#include "../input/input_driver.h"
|
#include "../input/input_driver.h"
|
||||||
#include "../configuration.h"
|
#include "../configuration.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned cheat_manager_get_buf_size(void)
|
unsigned cheat_manager_get_buf_size(void)
|
||||||
{
|
{
|
||||||
return cheat_manager_state.buf_size;
|
return cheat_manager_state.buf_size;
|
||||||
@ -227,7 +226,7 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = config_file_write(conf, cheats_file);
|
ret = config_file_write(conf, cheats_file, true);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -253,7 +253,7 @@ bool core_option_manager_flush(core_option_manager_t *opt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RARCH_LOG("Saved core options file to \"%s\"\n", opt->conf_path);
|
RARCH_LOG("Saved core options file to \"%s\"\n", opt->conf_path);
|
||||||
return config_file_write(opt->conf, opt->conf_path);
|
return config_file_write(opt->conf, opt->conf_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,7 +279,7 @@ bool core_option_manager_flush_game_specific(
|
|||||||
core_option_manager_get_val(opt, i));
|
core_option_manager_get_val(opt, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return config_file_write(opt->conf, path);
|
return config_file_write(opt->conf, path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3661,7 +3661,7 @@ static int action_ok_option_create(const char *path,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_file_write(conf, game_path))
|
if (config_file_write(conf, game_path, true))
|
||||||
{
|
{
|
||||||
runloop_msg_queue_push(
|
runloop_msg_queue_push(
|
||||||
msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY),
|
msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY),
|
||||||
|
@ -341,7 +341,7 @@ bool menu_shader_manager_save_preset(
|
|||||||
if (!string_is_empty(basename))
|
if (!string_is_empty(basename))
|
||||||
strlcpy(preset_path, buffer, sizeof(preset_path));
|
strlcpy(preset_path, buffer, sizeof(preset_path));
|
||||||
|
|
||||||
if (config_file_write(conf, preset_path))
|
if (config_file_write(conf, preset_path, true))
|
||||||
{
|
{
|
||||||
RARCH_LOG("Saved shader preset to %s.\n", preset_path);
|
RARCH_LOG("Saved shader preset to %s.\n", preset_path);
|
||||||
if (apply)
|
if (apply)
|
||||||
@ -361,7 +361,7 @@ bool menu_shader_manager_save_preset(
|
|||||||
fill_pathname_join(preset_path, dirs[d],
|
fill_pathname_join(preset_path, dirs[d],
|
||||||
buffer, sizeof(preset_path));
|
buffer, sizeof(preset_path));
|
||||||
|
|
||||||
if (config_file_write(conf, preset_path))
|
if (config_file_write(conf, preset_path, true))
|
||||||
{
|
{
|
||||||
RARCH_LOG("Saved shader preset to %s.\n", preset_path);
|
RARCH_LOG("Saved shader preset to %s.\n", preset_path);
|
||||||
if (apply)
|
if (apply)
|
||||||
|
@ -139,7 +139,7 @@ void CoreOptionsDialog::onSaveGameSpecificOptions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_file_write(conf, game_path))
|
if (config_file_write(conf, game_path, true))
|
||||||
{
|
{
|
||||||
runloop_msg_queue_push(
|
runloop_msg_queue_push(
|
||||||
msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY),
|
msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user