Refactor away core_info_get_custom_config
This commit is contained in:
parent
cc3835c915
commit
57dae32b66
|
@ -42,8 +42,7 @@ void apple_run_core(int argc, char **argv, const char* core,
|
||||||
strlcpy(core_path, core, sizeof(core_path));
|
strlcpy(core_path, core, sizeof(core_path));
|
||||||
|
|
||||||
strlcpy(config_path, g_defaults.config_path, sizeof(config_path));
|
strlcpy(config_path, g_defaults.config_path, sizeof(config_path));
|
||||||
if (core_info_has_custom_config(core))
|
core_info_has_custom_config(core, config_path, sizeof(config_path));
|
||||||
core_info_get_custom_config(core, config_path, sizeof(config_path));
|
|
||||||
|
|
||||||
static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 };
|
static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 };
|
||||||
static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 };
|
static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 };
|
||||||
|
|
|
@ -787,13 +787,11 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
||||||
rarch_setting_t *setting_data, *setting;
|
rarch_setting_t *setting_data, *setting;
|
||||||
NSMutableArray* settings;
|
NSMutableArray* settings;
|
||||||
|
|
||||||
_isCustom = core_info_has_custom_config(core.UTF8String);
|
_isCustom = core_info_has_custom_config(core.UTF8String, buffer, sizeof(buffer));
|
||||||
if (_isCustom)
|
if (_isCustom)
|
||||||
{
|
{
|
||||||
const core_info_t *tmp = (const core_info_t*)core_info_list_get_by_id(core.UTF8String);
|
const core_info_t *tmp = (const core_info_t*)core_info_list_get_by_id(core.UTF8String);
|
||||||
self.title = tmp ? BOXSTRING(tmp->display_name) : BOXSTRING(core.UTF8String);
|
self.title = tmp ? BOXSTRING(tmp->display_name) : BOXSTRING(core.UTF8String);
|
||||||
|
|
||||||
core_info_get_custom_config(core.UTF8String, buffer, sizeof(buffer));
|
|
||||||
_pathToSave = BOXSTRING(buffer);
|
_pathToSave = BOXSTRING(buffer);
|
||||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteCustom)];
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteCustom)];
|
||||||
}
|
}
|
||||||
|
@ -979,11 +977,9 @@ static bool copy_config(const char *src_path, const char *dst_path)
|
||||||
RAMenuCoreList* list = [[RAMenuCoreList alloc] initWithPath:nil allowAutoDetect:false
|
RAMenuCoreList* list = [[RAMenuCoreList alloc] initWithPath:nil allowAutoDetect:false
|
||||||
action:^(NSString* core)
|
action:^(NSString* core)
|
||||||
{
|
{
|
||||||
if (!core_info_has_custom_config(core.UTF8String))
|
char path[PATH_MAX];
|
||||||
|
if (!core_info_has_custom_config(core.UTF8String, path, sizeof(path)))
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
|
||||||
core_info_get_custom_config(core.UTF8String, path, sizeof(path));
|
|
||||||
|
|
||||||
if (g_defaults.config_path[0] != '\0' && path[0] != '\0')
|
if (g_defaults.config_path[0] != '\0' && path[0] != '\0')
|
||||||
{
|
{
|
||||||
if (!copy_config(g_defaults.config_path, path))
|
if (!copy_config(g_defaults.config_path, path))
|
||||||
|
|
19
core_info.c
19
core_info.c
|
@ -456,26 +456,17 @@ const core_info_t *core_info_list_get_by_id(const char *core_id)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void core_info_get_custom_config(const char *core_id, char *buf, size_t sizeof_buf)
|
bool core_info_has_custom_config(const char *core_id,
|
||||||
|
char *buf, size_t sizeof_buf)
|
||||||
{
|
{
|
||||||
if (!core_id || !buf || !sizeof_buf)
|
if (!core_id || !buf || !sizeof_buf)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
fill_pathname_join(buf, g_defaults.menu_config_dir, path_basename(core_id), sizeof_buf);
|
fill_pathname_join(buf, g_defaults.menu_config_dir, path_basename(core_id), sizeof_buf);
|
||||||
fill_pathname(buf, buf, ".cfg", sizeof_buf);
|
fill_pathname(buf, buf, ".cfg", sizeof_buf);
|
||||||
}
|
|
||||||
|
|
||||||
bool core_info_has_custom_config(const char *core_id)
|
if (buf[0] == '\0')
|
||||||
{
|
|
||||||
char path[PATH_MAX];
|
|
||||||
|
|
||||||
if (!core_id)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
core_info_get_custom_config(core_id, path, sizeof(path));
|
return path_file_exists(buf);
|
||||||
|
|
||||||
if (path[0] != '\0')
|
|
||||||
return path_file_exists(path);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,7 @@ void core_info_set_core_path(void);
|
||||||
core_info_list_t *core_info_list_get(void);
|
core_info_list_t *core_info_list_get(void);
|
||||||
const core_info_t *core_info_list_get_by_id(const char *core_id);
|
const core_info_t *core_info_list_get_by_id(const char *core_id);
|
||||||
|
|
||||||
void core_info_get_custom_config(const char *core_id, char *buf, size_t sizeof_buf);
|
bool core_info_has_custom_config(const char *core_id, char *buf, size_t sizeof_buf);
|
||||||
bool core_info_has_custom_config(const char *core_id);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue