mirror of
https://github.com/libretro/RetroArch
synced 2025-02-26 15:39:55 +00:00
Cleanup core_info_get_name - reuse core_info_list_iterate
This commit is contained in:
parent
c7b9625460
commit
eb33197a9b
91
core_info.c
91
core_info.c
@ -159,6 +159,34 @@ static void core_info_list_free(core_info_list_t *core_info_list)
|
|||||||
free(core_info_list);
|
free(core_info_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static config_file_t *core_info_list_iterate(struct string_list *contents, size_t i)
|
||||||
|
{
|
||||||
|
char info_path_base[PATH_MAX_LENGTH];
|
||||||
|
char info_path[PATH_MAX_LENGTH];
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!contents->elems[i].data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
fill_pathname_base(info_path_base, contents->elems[i].data,
|
||||||
|
sizeof(info_path_base));
|
||||||
|
path_remove_extension(info_path_base);
|
||||||
|
|
||||||
|
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP))
|
||||||
|
char *substr = strrchr(info_path_base, '_');
|
||||||
|
if (substr)
|
||||||
|
*substr = '\0';
|
||||||
|
#endif
|
||||||
|
|
||||||
|
strlcat(info_path_base, ".info", sizeof(info_path_base));
|
||||||
|
|
||||||
|
fill_pathname_join(info_path, (*settings->libretro_info_path) ?
|
||||||
|
settings->libretro_info_path : settings->libretro_directory,
|
||||||
|
info_path_base, sizeof(info_path));
|
||||||
|
|
||||||
|
return config_file_new(info_path);
|
||||||
|
}
|
||||||
|
|
||||||
void core_info_get_name(const char *path, char *s, size_t len)
|
void core_info_get_name(const char *path, char *s, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -184,35 +212,12 @@ void core_info_get_name(const char *path, char *s, size_t len)
|
|||||||
|
|
||||||
for (i = 0; i < contents->size; i++)
|
for (i = 0; i < contents->size; i++)
|
||||||
{
|
{
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
char info_path_base[PATH_MAX_LENGTH] = {0};
|
|
||||||
char info_path[PATH_MAX_LENGTH] = {0};
|
|
||||||
|
|
||||||
core_info[i].path = strdup(contents->elems[i].data);
|
if (!string_is_equal(contents->elems[i].data, path))
|
||||||
|
continue;
|
||||||
if (!core_info[i].path)
|
|
||||||
break;
|
conf = core_info_list_iterate(contents, i);
|
||||||
|
|
||||||
if (!string_is_equal(core_info[i].path, path))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
fill_pathname_base(info_path_base, contents->elems[i].data,
|
|
||||||
sizeof(info_path_base));
|
|
||||||
path_remove_extension(info_path_base);
|
|
||||||
|
|
||||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP))
|
|
||||||
char *substr = strrchr(info_path_base, '_');
|
|
||||||
if (substr)
|
|
||||||
*substr = '\0';
|
|
||||||
#endif
|
|
||||||
|
|
||||||
strlcat(info_path_base, ".info", sizeof(info_path_base));
|
|
||||||
|
|
||||||
fill_pathname_join(info_path, (*settings->libretro_info_path) ?
|
|
||||||
settings->libretro_info_path : settings->libretro_directory,
|
|
||||||
info_path_base, sizeof(info_path));
|
|
||||||
|
|
||||||
conf = config_file_new(info_path);
|
|
||||||
|
|
||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
@ -221,6 +226,8 @@ void core_info_get_name(const char *path, char *s, size_t len)
|
|||||||
core_info[i].config_data = (void*)conf;
|
core_info[i].config_data = (void*)conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core_info[i].path = strdup(contents->elems[i].data);
|
||||||
|
|
||||||
strlcpy(s, core_info[i].core_name, len);
|
strlcpy(s, core_info[i].core_name, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,34 +245,6 @@ error:
|
|||||||
core_info_list_free(core_info_list);
|
core_info_list_free(core_info_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static config_file_t *core_info_list_iterate(struct string_list *contents, size_t i)
|
|
||||||
{
|
|
||||||
char info_path_base[PATH_MAX_LENGTH];
|
|
||||||
char info_path[PATH_MAX_LENGTH];
|
|
||||||
config_file_t *conf = NULL;
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (!contents->elems[i].data)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
fill_pathname_base(info_path_base, contents->elems[i].data,
|
|
||||||
sizeof(info_path_base));
|
|
||||||
path_remove_extension(info_path_base);
|
|
||||||
|
|
||||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP))
|
|
||||||
char *substr = strrchr(info_path_base, '_');
|
|
||||||
if (substr)
|
|
||||||
*substr = '\0';
|
|
||||||
#endif
|
|
||||||
|
|
||||||
strlcat(info_path_base, ".info", sizeof(info_path_base));
|
|
||||||
|
|
||||||
fill_pathname_join(info_path, (*settings->libretro_info_path) ?
|
|
||||||
settings->libretro_info_path : settings->libretro_directory,
|
|
||||||
info_path_base, sizeof(info_path));
|
|
||||||
|
|
||||||
return config_file_new(info_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static core_info_list_t *core_info_list_new(void)
|
static core_info_list_t *core_info_list_new(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user