Refactor away core_info_get_custom_config

This commit is contained in:
twinaphex 2014-08-17 17:42:45 +02:00
parent cc3835c915
commit 57dae32b66
4 changed files with 10 additions and 25 deletions

View File

@ -42,8 +42,7 @@ void apple_run_core(int argc, char **argv, const char* core,
strlcpy(core_path, core, sizeof(core_path));
strlcpy(config_path, g_defaults.config_path, sizeof(config_path));
if (core_info_has_custom_config(core))
core_info_get_custom_config(core, config_path, sizeof(config_path));
core_info_has_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_menu[] = { "retroarch", "-c", config_path, "--menu", 0 };

View File

@ -787,13 +787,11 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
rarch_setting_t *setting_data, *setting;
NSMutableArray* settings;
_isCustom = core_info_has_custom_config(core.UTF8String);
_isCustom = core_info_has_custom_config(core.UTF8String, buffer, sizeof(buffer));
if (_isCustom)
{
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);
core_info_get_custom_config(core.UTF8String, buffer, sizeof(buffer));
_pathToSave = BOXSTRING(buffer);
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
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 (!copy_config(g_defaults.config_path, path))

View File

@ -456,26 +456,17 @@ const core_info_t *core_info_list_get_by_id(const char *core_id)
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)
return;
return false;
fill_pathname_join(buf, g_defaults.menu_config_dir, path_basename(core_id), sizeof_buf);
fill_pathname(buf, buf, ".cfg", sizeof_buf);
}
bool core_info_has_custom_config(const char *core_id)
{
char path[PATH_MAX];
if (!core_id)
if (buf[0] == '\0')
return false;
core_info_get_custom_config(core_id, path, sizeof(path));
if (path[0] != '\0')
return path_file_exists(path);
return false;
return path_file_exists(buf);
}

View File

@ -92,8 +92,7 @@ void core_info_set_core_path(void);
core_info_list_t *core_info_list_get(void);
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);
bool core_info_has_custom_config(const char *core_id, char *buf, size_t sizeof_buf);
#ifdef __cplusplus
}