mirror of
https://github.com/libretro/RetroArch
synced 2025-03-14 10:21:46 +00:00
* Use fill_pathname more
* Get rid of strlen in some locations
This commit is contained in:
parent
f429b15250
commit
c09fd38c1d
@ -150,15 +150,11 @@ static void menu_action_setting_disp_set_label_remap_file_info(
|
||||
{
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
const char *remap_path = runloop_st->name.remapfile;
|
||||
const char *remap_file = NULL;
|
||||
|
||||
*w = 19;
|
||||
|
||||
if (!string_is_empty(remap_path))
|
||||
remap_file = path_basename_nocompression(remap_path);
|
||||
|
||||
if (!string_is_empty(remap_file))
|
||||
strlcpy(s, remap_file, len);
|
||||
strlcpy(s, path_basename_nocompression(remap_path), len);
|
||||
else
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
|
||||
|
||||
@ -174,15 +170,11 @@ static void menu_action_setting_disp_set_label_override_file_info(
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
const char *override_path = path_get(RARCH_PATH_CONFIG_OVERRIDE);
|
||||
const char *override_file = NULL;
|
||||
|
||||
*w = 19;
|
||||
|
||||
if (!string_is_empty(override_path))
|
||||
override_file = path_basename_nocompression(override_path);
|
||||
|
||||
if (!string_is_empty(override_file))
|
||||
strlcpy(s, override_file, len);
|
||||
strlcpy(s, path_basename_nocompression(override_path), len);
|
||||
else
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
|
||||
|
||||
|
@ -56,33 +56,31 @@ static int action_bind_label_playlist_collection_entry(
|
||||
const char *label, const char *path,
|
||||
char *s, size_t len)
|
||||
{
|
||||
const char *playlist_file = NULL;
|
||||
|
||||
if (string_is_empty(path))
|
||||
return 0;
|
||||
|
||||
playlist_file = path_basename_nocompression(path);
|
||||
|
||||
if (string_is_empty(playlist_file))
|
||||
return 0;
|
||||
|
||||
if (string_is_equal_noncase(path_get_extension(playlist_file),
|
||||
"lpl"))
|
||||
if (!string_is_empty(path))
|
||||
{
|
||||
/* Handle content history */
|
||||
if (string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY))
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HISTORY_TAB), len);
|
||||
/* Handle favourites */
|
||||
else if (string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES))
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB), len);
|
||||
/* Handle collection playlists */
|
||||
else
|
||||
fill_pathname(s, playlist_file, "", len);
|
||||
const char *playlist_file = path_basename_nocompression(path);
|
||||
|
||||
if (!string_is_empty(playlist_file))
|
||||
{
|
||||
if (string_is_equal_noncase(path_get_extension(playlist_file),
|
||||
"lpl"))
|
||||
{
|
||||
/* Handle content history */
|
||||
if (string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY))
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HISTORY_TAB), len);
|
||||
/* Handle favourites */
|
||||
else if (string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES))
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB), len);
|
||||
/* Handle collection playlists */
|
||||
else
|
||||
fill_pathname(s, playlist_file, "", len);
|
||||
}
|
||||
/* This should never happen, but if it does just set
|
||||
* the label to the file name (it's better than nothing...) */
|
||||
else
|
||||
strlcpy(s, playlist_file, len);
|
||||
}
|
||||
}
|
||||
/* This should never happen, but if it does just set
|
||||
* the label to the file name (it's better than nothing...) */
|
||||
else
|
||||
strlcpy(s, playlist_file, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2289,10 +2289,9 @@ static void materialui_refresh_playlist_icon_list(
|
||||
|
||||
for (i = 0; i < file_list->size; i++)
|
||||
{
|
||||
size_t _len;
|
||||
const char *path = file_list->elems[i].data;
|
||||
const char *playlist_file = NULL;
|
||||
char image_file[256];
|
||||
char image_file[NAME_MAX_LENGTH];
|
||||
|
||||
/* We used malloc() to create the icons
|
||||
* array - ensure struct members are
|
||||
@ -2322,12 +2321,8 @@ static void materialui_refresh_playlist_icon_list(
|
||||
continue;
|
||||
|
||||
/* Playlist is valid - generate image file name */
|
||||
_len = strlcpy(image_file,
|
||||
playlist_file, sizeof(image_file));
|
||||
/* Manually rename extension 'lpl' to 'png' in string */
|
||||
image_file[_len-3] = 'p';
|
||||
image_file[_len-2] = 'n';
|
||||
image_file[_len-1] = 'g';
|
||||
fill_pathname(image_file, playlist_file,
|
||||
".png", sizeof(image_file));
|
||||
|
||||
/* All good - cache paths */
|
||||
mui->textures.playlist.icons[i].playlist_file = strdup(playlist_file);
|
||||
|
@ -9362,10 +9362,8 @@ static void ozone_context_reset(void *data, bool is_threaded)
|
||||
char filename[64];
|
||||
#ifdef HAVE_DISCORD_OWN_AVATAR
|
||||
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
|
||||
{
|
||||
size_t _len = strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
|
||||
strlcpy(filename + _len, FILE_PATH_PNG_EXTENSION, sizeof(filename) - _len);
|
||||
}
|
||||
fill_pathname(filename, discord_get_own_avatar(),
|
||||
".png", sizeof(filename));
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
@ -914,9 +914,7 @@ static int menu_displaylist_parse_core_info(
|
||||
|
||||
if (core_path)
|
||||
{
|
||||
size_t _len;
|
||||
|
||||
_len = strlcpy(tmp,
|
||||
size_t _len = strlcpy(tmp,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_PATH),
|
||||
sizeof(tmp));
|
||||
tmp[ _len] = ':';
|
||||
|
@ -3175,12 +3175,13 @@ static bool menu_shader_manager_operate_auto_preset(
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(auto_preset_dirs); i++)
|
||||
{
|
||||
size_t _len2;
|
||||
if (string_is_empty(auto_preset_dirs[i]))
|
||||
continue;
|
||||
|
||||
fill_pathname_join(preset_path,
|
||||
_len2 = fill_pathname_join(preset_path,
|
||||
auto_preset_dirs[i], file, sizeof(preset_path));
|
||||
end = preset_path + strlen(preset_path);
|
||||
end = preset_path + _len2;
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(shader_types); j++)
|
||||
{
|
||||
@ -3219,12 +3220,13 @@ static bool menu_shader_manager_operate_auto_preset(
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(auto_preset_dirs); i++)
|
||||
{
|
||||
size_t _len2;
|
||||
if (string_is_empty(auto_preset_dirs[i]))
|
||||
continue;
|
||||
|
||||
fill_pathname_join(preset_path,
|
||||
_len2 = fill_pathname_join(preset_path,
|
||||
auto_preset_dirs[i], file, sizeof(preset_path));
|
||||
end = preset_path + strlen(preset_path);
|
||||
end = preset_path + _len2;
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(shader_types); j++)
|
||||
{
|
||||
|
82
runloop.c
82
runloop.c
@ -4198,14 +4198,10 @@ static bool runloop_path_init_subsystem(runloop_state_t *runloop_st)
|
||||
from the main SRAM location. */
|
||||
if (!retroarch_override_setting_is_set(
|
||||
RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL))
|
||||
{
|
||||
size_t len = strlcpy(runloop_st->name.savefile,
|
||||
fill_pathname(runloop_st->name.savefile,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.savefile));
|
||||
strlcpy(runloop_st->name.savefile + len,
|
||||
".srm",
|
||||
sizeof(runloop_st->name.savefile) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.savefile));
|
||||
|
||||
if (path_is_directory(runloop_st->name.savefile))
|
||||
{
|
||||
@ -4883,44 +4879,28 @@ void runloop_path_fill_names(void)
|
||||
return;
|
||||
|
||||
if (string_is_empty(runloop_st->name.ups))
|
||||
{
|
||||
size_t len = strlcpy(runloop_st->name.ups,
|
||||
fill_pathname(runloop_st->name.ups,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.ups));
|
||||
strlcpy(runloop_st->name.ups + len,
|
||||
".ups",
|
||||
sizeof(runloop_st->name.ups) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.ups));
|
||||
|
||||
if (string_is_empty(runloop_st->name.bps))
|
||||
{
|
||||
size_t len = strlcpy(runloop_st->name.bps,
|
||||
fill_pathname(runloop_st->name.bps,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.bps));
|
||||
strlcpy(runloop_st->name.bps + len,
|
||||
".bps",
|
||||
sizeof(runloop_st->name.bps) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.bps));
|
||||
|
||||
if (string_is_empty(runloop_st->name.ips))
|
||||
{
|
||||
size_t len = strlcpy(runloop_st->name.ips,
|
||||
fill_pathname(runloop_st->name.ips,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.ips));
|
||||
strlcpy(runloop_st->name.ips + len,
|
||||
".ips",
|
||||
sizeof(runloop_st->name.ips) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.ips));
|
||||
|
||||
if (string_is_empty(runloop_st->name.xdelta))
|
||||
{
|
||||
size_t len = strlcpy(runloop_st->name.xdelta,
|
||||
fill_pathname(runloop_st->name.xdelta,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.xdelta));
|
||||
strlcpy(runloop_st->name.xdelta + len,
|
||||
".xdelta",
|
||||
sizeof(runloop_st->name.xdelta) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.xdelta));
|
||||
}
|
||||
|
||||
|
||||
@ -7878,52 +7858,35 @@ void runloop_path_set_names(void)
|
||||
runloop_state_t *runloop_st = &runloop_state;
|
||||
if (!retroarch_override_setting_is_set(
|
||||
RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL))
|
||||
{
|
||||
size_t len = strlcpy(runloop_st->name.savefile,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.savefile));
|
||||
strlcpy(runloop_st->name.savefile + len,
|
||||
".srm",
|
||||
sizeof(runloop_st->name.savefile) - len);
|
||||
}
|
||||
fill_pathname(runloop_st->name.savefile,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
".srm",
|
||||
sizeof(runloop_st->name.savefile));
|
||||
|
||||
if (!retroarch_override_setting_is_set(
|
||||
RARCH_OVERRIDE_SETTING_STATE_PATH, NULL))
|
||||
{
|
||||
size_t len = strlcpy(
|
||||
runloop_st->name.savestate,
|
||||
fill_pathname(runloop_st->name.savestate,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.savestate));
|
||||
strlcpy(runloop_st->name.savestate + len,
|
||||
".state",
|
||||
sizeof(runloop_st->name.savestate) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.savestate));
|
||||
|
||||
#ifdef HAVE_BSV_MOVIE
|
||||
if (!retroarch_override_setting_is_set(
|
||||
RARCH_OVERRIDE_SETTING_STATE_PATH, NULL))
|
||||
{
|
||||
size_t len = strlcpy(
|
||||
fill_pathname(
|
||||
runloop_st->name.replay,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.replay));
|
||||
strlcpy(runloop_st->name.replay + len,
|
||||
".replay",
|
||||
sizeof(runloop_st->name.replay) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.replay));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHEATS
|
||||
if (!string_is_empty(runloop_st->runtime_content_path_basename))
|
||||
{
|
||||
size_t len = strlcpy(
|
||||
fill_pathname(
|
||||
runloop_st->name.cheatfile,
|
||||
runloop_st->runtime_content_path_basename,
|
||||
sizeof(runloop_st->name.cheatfile));
|
||||
strlcpy(runloop_st->name.cheatfile + len,
|
||||
".cht",
|
||||
sizeof(runloop_st->name.cheatfile) - len);
|
||||
}
|
||||
sizeof(runloop_st->name.cheatfile));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -8025,7 +7988,6 @@ void runloop_path_set_redirect(settings_t *settings,
|
||||
RARCH_LOG("%s %s\n",
|
||||
msg_hash_to_str(MSG_REVERTING_SAVEFILE_DIRECTORY_TO),
|
||||
intermediate_savefile_dir);
|
||||
|
||||
strlcpy(new_savefile_dir, intermediate_savefile_dir, sizeof(new_savefile_dir));
|
||||
}
|
||||
}
|
||||
@ -8198,9 +8160,9 @@ void runloop_path_set_special(char **argv, unsigned num_content)
|
||||
if (is_dir)
|
||||
{
|
||||
strlcpy(runloop_st->name.savestate, savestate_dir,
|
||||
sizeof(runloop_st->name.savestate)); /* TODO/FIXME - why are we setting this string here but then later overwriting it later with fill_pathname_dir? */
|
||||
sizeof(runloop_st->name.savestate));
|
||||
strlcpy(runloop_st->name.replay, savestate_dir,
|
||||
sizeof(runloop_st->name.replay)); /* TODO/FIXME - as above */
|
||||
sizeof(runloop_st->name.replay));
|
||||
}
|
||||
else
|
||||
is_dir = path_is_directory(runloop_st->name.savestate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user