use path_basename_nocompression where it is safe to do so

This commit is contained in:
libretroadmin 2022-07-12 19:14:12 +02:00
parent 69ddf03c91
commit f7194e167f
8 changed files with 25 additions and 24 deletions

View File

@ -275,7 +275,7 @@ static const char *ctr_texture_path(unsigned id)
snprintf(texture_path, sizeof(texture_path),
"%s.png", state_path);
return path_basename(texture_path);
return path_basename_nocompression(texture_path);
}
default:
break;

View File

@ -2950,7 +2950,7 @@ void input_config_set_device_config_path(unsigned port, const char *path)
if (fill_pathname_parent_dir_name(parent_dir_name,
path, sizeof(parent_dir_name)))
fill_pathname_join(input_st->input_device_info[port].config_path,
parent_dir_name, path_basename(path),
parent_dir_name, path_basename_nocompression(path),
sizeof(input_st->input_device_info[port].config_path));
}
}
@ -3036,8 +3036,8 @@ const char *input_config_get_mouse_display_name(unsigned port)
void input_config_set_mouse_display_name(unsigned port, const char *name)
{
char name_ascii[NAME_MAX_LENGTH];
input_driver_state_t *input_st = &input_driver_st;
char name_ascii[256];
name_ascii[0] = '\0';
@ -3081,7 +3081,7 @@ void config_read_keybinds_conf(void *data)
for (j = 0; input_config_bind_map_get_valid(j); j++)
{
char str[256];
char str[NAME_MAX_LENGTH];
const struct input_bind_map *keybind =
(const struct input_bind_map*)INPUT_CONFIG_BIND_MAP_GET(j);
struct retro_keybind *bind = &input_config_binds[i][j];

View File

@ -635,7 +635,7 @@ static int action_start_core_lock(
core_name = core_info->display_name;
/* If not, use core file name */
else
core_name = path_basename(core_path);
core_name = path_basename_nocompression(core_path);
/* Build error message */
strlcpy(msg, msg_hash_to_str(MSG_CORE_UNLOCK_FAILED), sizeof(msg));
@ -696,7 +696,7 @@ static int action_start_core_set_standalone_exempt(
core_name = core_info->display_name;
/* If not, use core file name */
else
core_name = path_basename(core_path);
core_name = path_basename_nocompression(core_path);
/* Build error message */
strlcpy(msg,

View File

@ -1097,7 +1097,7 @@ static bool validate_game_options(
const char *core_name,
char *s, size_t len, bool mkdir)
{
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
const char *game_name = path_basename_nocompression(path_get(RARCH_PATH_BASENAME));
return validate_per_core_options(s, len, mkdir,
core_name, game_name);
}
@ -4310,8 +4310,9 @@ static void *input_list_element_constructor(void)
element->port = 0;
element->device = 0;
element->index = 0;
element->state = (int16_t*)calloc(256, sizeof(int16_t));
element->state_size = 256;
element->state = (int16_t*)calloc(NAME_MAX_LENGTH,
sizeof(int16_t));
element->state_size = NAME_MAX_LENGTH;
return ptr;
}
@ -6215,7 +6216,7 @@ void core_options_flush(void)
/* Get options file name for display purposes */
if (!string_is_empty(path_core_options))
core_options_file = path_basename(path_core_options);
core_options_file = path_basename_nocompression(path_core_options);
if (string_is_empty(core_options_file))
core_options_file = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN);

View File

@ -117,7 +117,7 @@ static void task_audio_mixer_handle_upload_ogg(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -149,7 +149,7 @@ static void task_audio_mixer_handle_upload_ogg_and_play(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -181,7 +181,7 @@ static void task_audio_mixer_handle_upload_flac(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -213,7 +213,7 @@ static void task_audio_mixer_handle_upload_flac_and_play(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -245,7 +245,7 @@ static void task_audio_mixer_handle_upload_mp3(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -277,7 +277,7 @@ static void task_audio_mixer_handle_upload_mp3_and_play(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -309,7 +309,7 @@ static void task_audio_mixer_handle_upload_mod(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -341,7 +341,7 @@ static void task_audio_mixer_handle_upload_mod_and_play(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -374,7 +374,7 @@ static void task_audio_mixer_handle_upload_wav(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
@ -406,7 +406,7 @@ static void task_audio_mixer_handle_upload_wav_and_play(retro_task_t *task,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename_nocompression(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);

View File

@ -757,7 +757,7 @@ static int database_info_list_iterate_found_match(
entry_path_str[0] = '\0';
fill_pathname(db_playlist_base_str,
path_basename(db_path), "", str_len);
path_basename_nocompression(db_path), "", str_len);
path_remove_extension(db_playlist_base_str);
strlcat(db_playlist_base_str, ".lpl", str_len);

View File

@ -637,7 +637,7 @@ static bool apply_patch_content(uint8_t **buf,
/* Show an OSD message */
if (show_notification)
{
const char *patch_filename = path_basename(patch_path);
const char *patch_filename = path_basename_nocompression(patch_path);
char msg[256];
msg[0] = '\0';

View File

@ -301,14 +301,14 @@ static bool screenshot_dump(
screenshot_name = system_info.library_name;
}
else
screenshot_name = path_basename(name_base);
screenshot_name = path_basename_nocompression(name_base);
fill_str_dated_filename(state->shotname, screenshot_name,
IMG_EXT, sizeof(state->shotname));
}
else
{
strlcpy(state->shotname, path_basename(name_base),
strlcpy(state->shotname, path_basename_nocompression(name_base),
sizeof(state->shotname));
strlcat(state->shotname, ".png", sizeof(state->shotname));
}