mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 00:32:49 +00:00
Create path_get_extension_mutable and use it in menu_explore function
for trivial extension replacement in string
This commit is contained in:
parent
94ed25be56
commit
c7786a45e1
@ -214,6 +214,26 @@ const char *path_get_extension(const char *path)
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* path_get_extension_mutable:
|
||||
* @path : path
|
||||
*
|
||||
* Specialized version of path_get_extension(). Return
|
||||
* value is mutable.
|
||||
*
|
||||
* Gets extension of file. Only '.'s
|
||||
* after the last slash are considered.
|
||||
*
|
||||
* @return extension part from the path.
|
||||
**/
|
||||
char *path_get_extension_mutable(const char *path)
|
||||
{
|
||||
char *ext = NULL;
|
||||
if (!string_is_empty(path) && ((ext = strrchr(path_basename(path), '.'))))
|
||||
return ext;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* path_remove_extension:
|
||||
* @path : path
|
||||
|
@ -126,6 +126,20 @@ const char *path_get_archive_delim(const char *path);
|
||||
**/
|
||||
const char *path_get_extension(const char *path);
|
||||
|
||||
/**
|
||||
* path_get_extension_mutable:
|
||||
* @path : path
|
||||
*
|
||||
* Specialized version of path_get_extension(). Return
|
||||
* value is mutable.
|
||||
*
|
||||
* Gets extension of file. Only '.'s
|
||||
* after the last slash are considered.
|
||||
*
|
||||
* @return extension part from the path.
|
||||
**/
|
||||
char *path_get_extension_mutable(const char *path);
|
||||
|
||||
/**
|
||||
* path_remove_extension:
|
||||
* @path : path
|
||||
|
@ -522,8 +522,9 @@ explore_state_t *menu_explore_build_list(const char *directory_playlist,
|
||||
rdb_num = RHMAP_GET(rdb_indices, rdb_hash);
|
||||
if (!rdb_num)
|
||||
{
|
||||
struct explore_rdb newrdb;
|
||||
size_t systemname_len;
|
||||
struct explore_rdb newrdb;
|
||||
char *ext_path = NULL;
|
||||
|
||||
newrdb.handle = libretrodb_new();
|
||||
newrdb.count = 0;
|
||||
@ -538,8 +539,18 @@ explore_state_t *menu_explore_build_list(const char *directory_playlist,
|
||||
|
||||
fill_pathname_join_special(
|
||||
tmp, directory_database, db_name, sizeof(tmp));
|
||||
path_remove_extension(tmp);
|
||||
strlcat(tmp, ".rdb", sizeof(tmp));
|
||||
|
||||
/* Replace the extension - change 'lpl' to 'rdb' */
|
||||
if (( ext_path = path_get_extension_mutable(tmp))
|
||||
&& ext_path[0] == '.'
|
||||
&& ext_path[1] == 'l'
|
||||
&& ext_path[2] == 'p'
|
||||
&& ext_path[3] == 'l')
|
||||
{
|
||||
ext_path[1] = 'r';
|
||||
ext_path[2] = 'd';
|
||||
ext_path[3] = 'b';
|
||||
}
|
||||
|
||||
if (libretrodb_open(tmp, newrdb.handle) != 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user