Skip to content

Commit

Permalink
(menu_explore) Simplification of explore_load_icons
Browse files Browse the repository at this point in the history
fill_pathname_application_special - return size_t
  • Loading branch information
LibretroAdmin committed Dec 30, 2024
1 parent 28f6ee9 commit 8ebedcb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
44 changes: 23 additions & 21 deletions file_path_special.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ bool fill_pathname_application_data(char *s, size_t len)
const char* xmb_theme_ident(void);
#endif

void fill_pathname_application_special(char *s,
size_t fill_pathname_application_special(char *s,
size_t len, enum application_special_type type)
{
size_t _len = 0;
switch (type)
{
case APPLICATION_SPECIAL_DIRECTORY_CONFIG:
Expand All @@ -202,9 +203,9 @@ void fill_pathname_application_special(char *s,
/* Try config directory setting first,
* fallback to the location of the current configuration file. */
if (!string_is_empty(dir_menu_config))
strlcpy(s, dir_menu_config, len);
_len = strlcpy(s, dir_menu_config, len);
else if (!path_is_empty(RARCH_PATH_CONFIG))
fill_pathname_basedir(s, path_get(RARCH_PATH_CONFIG), len);
_len = fill_pathname_basedir(s, path_get(RARCH_PATH_CONFIG), len);
}
break;
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS:
Expand All @@ -216,7 +217,7 @@ void fill_pathname_application_special(char *s,
const char *dir_assets = settings->paths.directory_assets;
fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir));
fill_pathname_join_special(tmp_path, tmp_dir, xmb_theme_ident(), sizeof(tmp_path));
fill_pathname_join_special(s, tmp_path, "png", len);
_len = fill_pathname_join_special(s, tmp_path, "png", len);
}
#endif
break;
Expand All @@ -227,7 +228,7 @@ void fill_pathname_application_special(char *s,
const char *path_menu_wallpaper = settings->paths.path_menu_wallpaper;

if (!string_is_empty(path_menu_wallpaper))
strlcpy(s, path_menu_wallpaper, len);
_len = strlcpy(s, path_menu_wallpaper, len);
else
{
char tmp_dir[DIR_MAX_LENGTH];
Expand All @@ -237,7 +238,7 @@ void fill_pathname_application_special(char *s,
fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir));
fill_pathname_join_special(tmp_dir2, tmp_dir, xmb_theme_ident(), sizeof(tmp_dir2));
fill_pathname_join_special(tmp_path, tmp_dir2, "png", sizeof(tmp_path));
fill_pathname_join_special(s, tmp_path, FILE_PATH_BACKGROUND_IMAGE, len);
_len = fill_pathname_join_special(s, tmp_path, FILE_PATH_BACKGROUND_IMAGE, len);
}
}
#endif
Expand All @@ -258,7 +259,7 @@ void fill_pathname_application_special(char *s,
char tmp_path[PATH_MAX_LENGTH];
fill_pathname_join_special(tmp_dir, dir_assets, menu_ident, sizeof(tmp_dir));
fill_pathname_join_special(tmp_path, tmp_dir, xmb_theme_ident(), sizeof(tmp_path));
fill_pathname_join_special(s, tmp_path, "sounds", len);
_len = fill_pathname_join_special(s, tmp_path, "sounds", len);
}
else
#endif
Expand All @@ -268,12 +269,12 @@ void fill_pathname_application_special(char *s,
{
char tmp_dir[DIR_MAX_LENGTH];
fill_pathname_join_special(tmp_dir, dir_assets, menu_ident, sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "sounds", len);
_len = fill_pathname_join_special(s, tmp_dir, "sounds", len);
}
else
#endif
{
fill_pathname_join_special(
_len = fill_pathname_join_special(
s, dir_assets, "sounds", len);
}
#endif
Expand All @@ -296,7 +297,7 @@ void fill_pathname_application_special(char *s,
const char *dir_assets = settings->paths.directory_assets;
fill_pathname_join_special(tmp_dir, dir_assets, menu_ident, sizeof(tmp_dir));
fill_pathname_join_special(tmp_path, tmp_dir, xmb_theme_ident(), sizeof(tmp_path));
fill_pathname_join_special(s, tmp_path, "png", len);
_len = fill_pathname_join_special(s, tmp_path, "png", len);
}
else
#endif
Expand All @@ -317,7 +318,7 @@ void fill_pathname_application_special(char *s,
fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir));
fill_pathname_join_special(tmp_path, "monochrome", "png", sizeof(tmp_path));
#endif
fill_pathname_join_special(s, tmp_dir, tmp_path, len);
_len = fill_pathname_join_special(s, tmp_dir, tmp_path, len);
}
else
#endif
Expand All @@ -342,7 +343,7 @@ void fill_pathname_application_special(char *s,
fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir));
fill_pathname_join_special(tmp_path, "monochrome", "png", sizeof(tmp_path));
#endif
fill_pathname_join_special(s, tmp_dir, tmp_path, len);
_len = fill_pathname_join_special(s, tmp_dir, tmp_path, len);
}
#endif
break;
Expand All @@ -354,7 +355,7 @@ void fill_pathname_application_special(char *s,
settings_t *settings = config_get_ptr();
const char *dir_assets = settings->paths.directory_assets;
fill_pathname_join_special(tmp_dir, dir_assets, "rgui", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "font", len);
_len = fill_pathname_join_special(s, tmp_dir, "font", len);
}
#endif
break;
Expand All @@ -366,7 +367,7 @@ void fill_pathname_application_special(char *s,
settings_t *settings = config_get_ptr();
const char *dir_assets = settings->paths.directory_assets;
fill_pathname_join_special(tmp_dir, dir_assets, "xmb", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, xmb_theme_ident(), len);
_len = fill_pathname_join_special(s, tmp_dir, xmb_theme_ident(), len);
}
#endif
break;
Expand All @@ -377,7 +378,7 @@ void fill_pathname_application_special(char *s,
const char *path_menu_xmb_font = settings->paths.path_menu_xmb_font;

if (!string_is_empty(path_menu_xmb_font))
strlcpy(s, path_menu_xmb_font, len);
_len = strlcpy(s, path_menu_xmb_font, len);
else
{
char tmp_dir[DIR_MAX_LENGTH];
Expand All @@ -388,18 +389,18 @@ void fill_pathname_application_special(char *s,
case RETRO_LANGUAGE_PERSIAN:
fill_pathname_join_special(tmp_dir,
settings->paths.directory_assets, "pkg", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "fallback-font.ttf", len);
_len = fill_pathname_join_special(s, tmp_dir, "fallback-font.ttf", len);
break;
case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
fill_pathname_join_special(tmp_dir,
settings->paths.directory_assets, "pkg", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "chinese-fallback-font.ttf", len);
_len = fill_pathname_join_special(s, tmp_dir, "chinese-fallback-font.ttf", len);
break;
case RETRO_LANGUAGE_KOREAN:
fill_pathname_join_special(tmp_dir,
settings->paths.directory_assets, "pkg", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "korean-fallback-font.ttf", len);
_len = fill_pathname_join_special(s, tmp_dir, "korean-fallback-font.ttf", len);
break;
default:
{
Expand All @@ -408,7 +409,7 @@ void fill_pathname_application_special(char *s,
const char *dir_assets = settings->paths.directory_assets;
fill_pathname_join_special(tmp_dir2, dir_assets, "xmb", sizeof(tmp_dir2));
fill_pathname_join_special(tmp_dir, tmp_dir2, xmb_theme_ident(), sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, FILE_PATH_TTF_FONT, len);
_len = fill_pathname_join_special(s, tmp_dir, FILE_PATH_TTF_FONT, len);
}
break;
}
Expand All @@ -422,7 +423,7 @@ void fill_pathname_application_special(char *s,
settings_t *settings = config_get_ptr();
const char *dir_thumbnails = settings->paths.directory_thumbnails;
fill_pathname_join_special(tmp_dir, dir_thumbnails, "discord", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "avatars", len);
_len = fill_pathname_join_special(s, tmp_dir, "avatars", len);
}
break;

Expand All @@ -432,12 +433,13 @@ void fill_pathname_application_special(char *s,
settings_t *settings = config_get_ptr();
const char *dir_thumbnails = settings->paths.directory_thumbnails;
fill_pathname_join_special(tmp_dir, dir_thumbnails, "cheevos", sizeof(tmp_dir));
fill_pathname_join_special(s, tmp_dir, "badges", len);
_len = fill_pathname_join_special(s, tmp_dir, "badges", len);
}
break;

case APPLICATION_SPECIAL_NONE:
default:
break;
}
return _len;
}
2 changes: 1 addition & 1 deletion file_path_special.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ enum application_special_type

bool fill_pathname_application_data(char *s, size_t len);

void fill_pathname_application_special(char *s, size_t len, enum application_special_type type);
size_t fill_pathname_application_special(char *s, size_t len, enum application_special_type type);

RETRO_END_DECLS

Expand Down
2 changes: 1 addition & 1 deletion gfx/video_shader_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ static bool video_shader_write_referenced_preset(
* loaded presets are located
* and where Save Game Preset, Save Core Preset,
* Save Global Preset save to */
fill_pathname_application_special(config_dir, DIR_MAX_LENGTH,
fill_pathname_application_special(config_dir, sizeof(config_dir),
APPLICATION_SPECIAL_DIRECTORY_CONFIG);

/* If there is no initial preset path loaded */
Expand Down
2 changes: 1 addition & 1 deletion menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ static void xmb_render_messagebox_internal(
string_list_deinitialize(&list);
}

static char* xmb_path_dynamic_wallpaper(xmb_handle_t *xmb)
static char *xmb_path_dynamic_wallpaper(xmb_handle_t *xmb)
{
char path[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
Expand Down
7 changes: 3 additions & 4 deletions menu/menu_explore.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ static void explore_load_icons(explore_state_t *state)
{
struct texture_image ti;
size_t __len = _len;
__len += strlcpy(path + _len,
__len += fill_pathname(path + _len,
state->by[EXPLORE_BY_SYSTEM][i]->str,
".png",
sizeof(path) - _len);
strlcpy(path + __len, ".png", sizeof(path) - __len);
if (!path_is_valid(path))
continue;

Expand Down Expand Up @@ -1680,8 +1680,7 @@ SKIP_ENTRY:;
const struct playlist_entry *pl_entry =
state->entries[current_type - EXPLORE_TYPE_FIRSTITEM].playlist_entry;

strlcpy(state->title,
pl_entry->label, sizeof(state->title));
strlcpy(state->title, pl_entry->label, sizeof(state->title));

for (pl_idx = 0; pl_idx != (int)RBUF_LEN(state->playlists); pl_idx++)
{
Expand Down

0 comments on commit 8ebedcb

Please sign in to comment.