mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Start using path_ functions for accessing and modifying global->path.config
This commit is contained in:
parent
0aa2cf5019
commit
075599e818
17
command.c
17
command.c
@ -1480,14 +1480,12 @@ static bool command_event_save_core_config(void)
|
||||
bool found_path = false;
|
||||
bool overrides_active = false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
*config_dir = '\0';
|
||||
if (!string_is_empty(settings->directory.menu_config))
|
||||
strlcpy(config_dir, settings->directory.menu_config,
|
||||
sizeof(config_dir));
|
||||
else if (!string_is_empty(global->path.config)) /* Fallback */
|
||||
fill_pathname_basedir(config_dir, global->path.config,
|
||||
else if (!path_is_config_empty()) /* Fallback */
|
||||
fill_pathname_basedir(config_dir, path_get_config(),
|
||||
sizeof(config_dir));
|
||||
else
|
||||
{
|
||||
@ -1556,8 +1554,7 @@ static bool command_event_save_core_config(void)
|
||||
|
||||
if ((ret = config_save_file(config_path)))
|
||||
{
|
||||
strlcpy(global->path.config, config_path,
|
||||
sizeof(global->path.config));
|
||||
path_set_config(config_path);
|
||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
||||
config_path);
|
||||
@ -1594,10 +1591,8 @@ void command_event_save_current_config(int override_type)
|
||||
if (!override_type)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if ( settings->config_save_on_exit
|
||||
&& !string_is_empty(global->path.config))
|
||||
if (settings->config_save_on_exit && !path_is_config_empty())
|
||||
{
|
||||
bool ret = false;
|
||||
const char *config_path = path_get_config();
|
||||
@ -1615,14 +1610,14 @@ void command_event_save_current_config(int override_type)
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
|
||||
global->path.config);
|
||||
path_get_config());
|
||||
RARCH_LOG("%s\n", msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
|
||||
global->path.config);
|
||||
path_get_config());
|
||||
RARCH_ERR("%s\n", msg);
|
||||
}
|
||||
}
|
||||
|
@ -1336,7 +1336,6 @@ static config_file_t *open_default_config_file(void)
|
||||
char conf_path[PATH_MAX_LENGTH] = {0};
|
||||
char app_path[PATH_MAX_LENGTH] = {0};
|
||||
config_file_t *conf = NULL;
|
||||
global_t *global = NULL;
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
fill_pathname_application_path(app_path, sizeof(app_path));
|
||||
@ -1501,10 +1500,8 @@ static config_file_t *open_default_config_file(void)
|
||||
if (!conf)
|
||||
return NULL;
|
||||
|
||||
global = global_get_ptr();
|
||||
path_set_config(conf_path);
|
||||
|
||||
if (global)
|
||||
strlcpy(global->path.config, conf_path, sizeof(global->path.config));
|
||||
return conf;
|
||||
}
|
||||
|
||||
@ -1908,7 +1905,7 @@ static bool config_load_file(const char *path, bool set_defaults,
|
||||
{
|
||||
fill_pathname_resolve_relative(
|
||||
settings->path.content_history,
|
||||
global->path.config,
|
||||
path_get_config(),
|
||||
file_path_str(FILE_PATH_CONTENT_HISTORY),
|
||||
sizeof(settings->path.content_history));
|
||||
}
|
||||
@ -1927,7 +1924,7 @@ static bool config_load_file(const char *path, bool set_defaults,
|
||||
{
|
||||
fill_pathname_resolve_relative(
|
||||
settings->path.content_music_history,
|
||||
global->path.config,
|
||||
path_get_config(),
|
||||
file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY),
|
||||
sizeof(settings->path.content_music_history));
|
||||
}
|
||||
@ -1946,7 +1943,7 @@ static bool config_load_file(const char *path, bool set_defaults,
|
||||
{
|
||||
fill_pathname_resolve_relative(
|
||||
settings->path.content_video_history,
|
||||
global->path.config,
|
||||
path_get_config(),
|
||||
file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY),
|
||||
sizeof(settings->path.content_video_history));
|
||||
}
|
||||
@ -1965,7 +1962,7 @@ static bool config_load_file(const char *path, bool set_defaults,
|
||||
{
|
||||
fill_pathname_resolve_relative(
|
||||
settings->path.content_image_history,
|
||||
global->path.config,
|
||||
path_get_config(),
|
||||
file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY),
|
||||
sizeof(settings->path.content_image_history));
|
||||
}
|
||||
@ -2222,7 +2219,7 @@ bool config_load_override(void)
|
||||
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
|
||||
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH);
|
||||
|
||||
if (!config_load_file(global->path.config, false, config_get_ptr()))
|
||||
if (!config_load_file(path_get_config(), false, config_get_ptr()))
|
||||
return false;
|
||||
|
||||
/* Restore the libretro_path we're using
|
||||
@ -2258,7 +2255,7 @@ bool config_unload_override(void)
|
||||
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
|
||||
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH);
|
||||
|
||||
if (config_load_file(global->path.config, false, config_get_ptr()))
|
||||
if (config_load_file(path_get_config(), false, config_get_ptr()))
|
||||
{
|
||||
RARCH_LOG("[overrides] configuration overrides unloaded, original configuration restored.\n");
|
||||
|
||||
@ -2510,26 +2507,23 @@ bool config_load_shader_preset(void)
|
||||
|
||||
static void parse_config_file(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
bool ret = config_load_file((*global->path.config)
|
||||
? global->path.config : NULL, false, config_get_ptr());
|
||||
bool ret = config_load_file(path_get_config(), false, config_get_ptr());
|
||||
|
||||
if (!string_is_empty(global->path.config))
|
||||
if (!path_is_config_empty())
|
||||
{
|
||||
RARCH_LOG("Config: loading config from: %s.\n", global->path.config);
|
||||
RARCH_LOG("Config: loading config from: %s.\n", path_get_config());
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_LOG("Loading default config.\n");
|
||||
if (!string_is_empty(global->path.config))
|
||||
RARCH_LOG("Config: found default config: %s.\n", global->path.config);
|
||||
if (!path_is_config_empty())
|
||||
RARCH_LOG("Config: found default config: %s.\n", path_get_config());
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
RARCH_ERR("Config: couldn't find config at path: \"%s\"\n",
|
||||
global->path.config);
|
||||
RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", path_get_config());
|
||||
}
|
||||
|
||||
|
||||
@ -3062,7 +3056,7 @@ bool config_save_overrides(int override_type)
|
||||
conf = config_file_new(NULL);
|
||||
|
||||
/* Load the original config file in memory */
|
||||
config_load_file(global->path.config, false, settings);
|
||||
config_load_file(path_get_config(), false, settings);
|
||||
|
||||
bool_settings_size = populate_settings_bool(settings, &bool_settings);
|
||||
populate_settings_bool (overrides, &bool_overrides);
|
||||
@ -3187,20 +3181,19 @@ bool config_replace(char *path)
|
||||
{
|
||||
content_ctx_info_t content_info = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!path || !global)
|
||||
if (!path)
|
||||
return false;
|
||||
|
||||
/* If config file to be replaced is the same as the
|
||||
* current config file, exit. */
|
||||
if (string_is_equal(path, global->path.config))
|
||||
if (string_is_equal(path, path_get_config()))
|
||||
return false;
|
||||
|
||||
if (settings->config_save_on_exit && !string_is_empty(global->path.config))
|
||||
config_save_file(global->path.config);
|
||||
if (settings->config_save_on_exit && !path_is_config_empty())
|
||||
config_save_file(path_get_config());
|
||||
|
||||
strlcpy(global->path.config, path, sizeof(global->path.config));
|
||||
path_set_config(path);
|
||||
|
||||
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "configuration.h"
|
||||
#include "file_path_special.h"
|
||||
|
||||
#include "paths.h"
|
||||
#include "runloop.h"
|
||||
#include "verbosity.h"
|
||||
|
||||
@ -284,13 +285,13 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe
|
||||
case APPLICATION_SPECIAL_DIRECTORY_CONFIG:
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
/* Try config directory setting first,
|
||||
* fallback to the location of the current configuration file. */
|
||||
if (!string_is_empty(settings->directory.menu_config))
|
||||
strlcpy(s, settings->directory.menu_config, len);
|
||||
else if (!string_is_empty(global->path.config))
|
||||
fill_pathname_basedir(s, global->path.config, len);
|
||||
else if (!path_is_config_empty())
|
||||
fill_pathname_basedir(s, path_get_config(), len);
|
||||
}
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_ZARCH_ICONS:
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "../../managers/core_option_manager.h"
|
||||
#include "../../managers/cheat_manager.h"
|
||||
#include "../../performance_counters.h"
|
||||
#include "../../paths.h"
|
||||
#include "../../runloop.h"
|
||||
#include "../../intl/intl.h"
|
||||
|
||||
@ -125,12 +126,11 @@ static void menu_action_setting_disp_set_label_configurations(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
*w = 19;
|
||||
strlcpy(s2, path, len2);
|
||||
if (global && *global->path.config)
|
||||
fill_pathname_base(s, global->path.config,
|
||||
|
||||
if (!path_is_config_empty())
|
||||
fill_pathname_base(s, path_get_config(),
|
||||
len);
|
||||
else
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DIRECTORY_DEFAULT), len);
|
||||
|
@ -222,7 +222,6 @@ bool menu_shader_manager_save_preset(
|
||||
config_file_t *conf = NULL;
|
||||
bool ret = false;
|
||||
struct video_shader *shader = NULL;
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
menu_handle_t *menu = NULL;
|
||||
|
||||
@ -296,10 +295,10 @@ bool menu_shader_manager_save_preset(
|
||||
strlcpy(buffer, conf_path, sizeof(buffer));
|
||||
}
|
||||
|
||||
if (!string_is_empty(global->path.config))
|
||||
if (!path_is_config_empty())
|
||||
fill_pathname_basedir(
|
||||
config_directory,
|
||||
global->path.config,
|
||||
path_get_config(),
|
||||
sizeof(config_directory));
|
||||
|
||||
if (!fullpath)
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "../defaults.h"
|
||||
#include "../configuration.h"
|
||||
#include "../frontend/frontend.h"
|
||||
#include "../paths.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
@ -1604,8 +1605,8 @@ static void menu_content_environment_get(int *argc, char *argv[],
|
||||
wrap_args->state_path = NULL;
|
||||
wrap_args->content_path = NULL;
|
||||
|
||||
if (!string_is_empty(global->path.config))
|
||||
wrap_args->config_path = global->path.config;
|
||||
if (!path_is_config_empty())
|
||||
wrap_args->config_path = path_get_config();
|
||||
if (!string_is_empty(global->dir.savefile))
|
||||
wrap_args->sram_path = global->dir.savefile;
|
||||
if (!string_is_empty(global->dir.savestate))
|
||||
|
Loading…
x
Reference in New Issue
Block a user