diff --git a/dynamic.c b/dynamic.c index 44be0660a4..cae2a04c03 100644 --- a/dynamic.c +++ b/dynamic.c @@ -256,6 +256,33 @@ static void load_symbols(void) SYM(retro_get_memory_size); } +void get_libretro_core_name(char *name, size_t size) +{ + if (size == 0) + return; + + struct retro_system_info info; + retro_get_system_info(&info); + const char *id = info.library_name ? info.library_name : "Unknown"; + + if (!id || strlen(id) >= size) + { + name[0] = '\0'; + return; + } + + name[strlen(id)] = '\0'; + + for (size_t i = 0; id[i] != '\0'; i++) + { + char c = id[i]; + if (isspace(c) || isblank(c)) + name[i] = '_'; + else + name[i] = tolower(c); + } +} + void init_libretro_sym(void) { // Guarantee that we can do "dirty" casting. diff --git a/dynamic.h b/dynamic.h index dd94effc7f..a071ab2378 100644 --- a/dynamic.h +++ b/dynamic.h @@ -52,6 +52,9 @@ bool libretro_get_system_info(const char *path, struct retro_system_info *info); void libretro_free_system_info(struct retro_system_info *info); #endif +// Transforms a library id to a name suitable as a pathname. +void get_libretro_core_name(char *name, size_t size); + extern void (*pretro_init)(void); extern void (*pretro_deinit)(void); diff --git a/frontend/frontend_console.c b/frontend/frontend_console.c index 1019f2a676..f661ac54e8 100644 --- a/frontend/frontend_console.c +++ b/frontend/frontend_console.c @@ -115,39 +115,11 @@ static void verbose_log_init(void) } #ifdef HAVE_LIBRETRO_MANAGEMENT - -// Transforms a library id to a name suitable as a pathname. -static void get_libretro_core_name(char *name, size_t size) -{ - if (size == 0) - return; - - struct retro_system_info info; - retro_get_system_info(&info); - const char *id = info.library_name ? info.library_name : "Unknown"; - - if (!id || strlen(id) >= size) - { - name[0] = '\0'; - return; - } - - name[strlen(id)] = '\0'; - - for (size_t i = 0; id[i] != '\0'; i++) - { - char c = id[i]; - if (isspace(c) || isblank(c)) - name[i] = '_'; - else - name[i] = tolower(c); - } -} - -// If a CORE executable of name CORE.extension exists, rename filename -// to a more sane name. static bool install_libretro_core(const char *core_exe_path, const char *tmp_path, const char *extension) { + // If a CORE executable of name CORE.extension exists, rename filename + // to a more sane name. + int ret = 0; char tmp_path2[PATH_MAX], tmp_pathnewfile[PATH_MAX]; diff --git a/frontend/frontend_console.h b/frontend/frontend_console.h index 0634440469..ccb6d3cff7 100644 --- a/frontend/frontend_console.h +++ b/frontend/frontend_console.h @@ -27,6 +27,4 @@ static void find_first_libretro_core(char *first_file, const char * ext); #endif -static void get_libretro_core_name(char *name, size_t size); - #endif