Get rid of fill_pathname_join_concat_ext

This commit is contained in:
libretroadmin 2022-07-11 22:01:20 +02:00
parent b7926605f4
commit 293722ac38
4 changed files with 56 additions and 70 deletions

View File

@ -284,7 +284,7 @@ void fill_pathname(char *out_path, const char *in_path,
const char *replace, size_t size) const char *replace, size_t size)
{ {
char tmp_path[PATH_MAX_LENGTH]; char tmp_path[PATH_MAX_LENGTH];
char *tok = NULL; char *tok = NULL;
tmp_path[0] = '\0'; tmp_path[0] = '\0';
@ -381,15 +381,6 @@ size_t fill_pathname_base(char *out, const char *in_path, size_t size)
return strlcpy(out, in_path, size); return strlcpy(out, in_path, size);
} }
size_t fill_pathname_base_ext(char *out,
const char *in_path, const char *ext,
size_t size)
{
fill_pathname_base(out, in_path, size);
path_remove_extension(out);
return strlcat(out, ext, size);
}
/** /**
* fill_pathname_basedir: * fill_pathname_basedir:
* @out_dir : output directory * @out_dir : output directory
@ -524,7 +515,7 @@ size_t fill_dated_filename(char *out_filename,
void fill_str_dated_filename(char *out_filename, void fill_str_dated_filename(char *out_filename,
const char *in_str, const char *ext, size_t size) const char *in_str, const char *ext, size_t size)
{ {
char format[256]; char format[NAME_MAX_LENGTH];
struct tm tm_; struct tm tm_;
time_t cur_time = time(NULL); time_t cur_time = time(NULL);
@ -541,10 +532,9 @@ void fill_str_dated_filename(char *out_filename,
else else
{ {
strftime(format, sizeof(format), "-%y%m%d-%H%M%S.", &tm_); strftime(format, sizeof(format), "-%y%m%d-%H%M%S.", &tm_);
strlcpy(out_filename, in_str, size);
fill_pathname_join_concat_noext(out_filename, strlcat(out_filename, format, size);
in_str, format, ext, strlcat(out_filename, ext, size);
size);
} }
} }
@ -924,16 +914,6 @@ size_t fill_pathname_join_special_ext(char *out_path,
return strlcat(out_path, ext, size); return strlcat(out_path, ext, size);
} }
size_t fill_pathname_join_concat_noext(char *out_path,
const char *dir, const char *path,
const char *concat,
size_t size)
{
strlcpy(out_path, dir, size);
strlcat(out_path, path, size);
return strlcat(out_path, concat, size);
}
/** /**
* fill_pathname_join_delim: * fill_pathname_join_delim:
* @out_path : output path * @out_path : output path

View File

@ -308,10 +308,6 @@ size_t fill_pathname_dir(char *in_dir, const char *in_basename,
**/ **/
size_t fill_pathname_base(char *out_path, const char *in_path, size_t size); size_t fill_pathname_base(char *out_path, const char *in_path, size_t size);
size_t fill_pathname_base_ext(char *out,
const char *in_path, const char *ext,
size_t size);
/** /**
* fill_pathname_basedir: * fill_pathname_basedir:
* @out_dir : output directory * @out_dir : output directory
@ -387,11 +383,6 @@ size_t fill_pathname_join_special_ext(char *out_path,
const char *last, const char *ext, const char *last, const char *ext,
size_t size); size_t size);
size_t fill_pathname_join_concat_noext(char *out_path,
const char *dir, const char *path,
const char *concat,
size_t size);
/** /**
* fill_pathname_join_delim: * fill_pathname_join_delim:
* @out_path : output path * @out_path : output path

View File

@ -541,9 +541,11 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info,
if (!info_list[i].name) if (!info_list[i].name)
continue; continue;
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(info_list[i].msg), msg_hash_to_str(info_list[i].msg),
": ", sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp,
info_list[i].name, info_list[i].name,
sizeof(tmp)); sizeof(tmp));
if (menu_entries_append_enum(info->list, tmp, "", if (menu_entries_append_enum(info->list, tmp, "",
@ -656,11 +658,12 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info,
MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_DISABLED); MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_DISABLED);
break; break;
} }
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_SUPPORT_LEVEL), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_SUPPORT_LEVEL),
": ",
savestate_support,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, savestate_support, sizeof(tmp));
if (menu_entries_append_enum(info->list, tmp, "", if (menu_entries_append_enum(info->list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
count++; count++;
@ -1626,12 +1629,11 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
(void)tmp_string; (void)tmp_string;
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
fill_pathname_join_concat_noext( strlcpy(tmp,
tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION),
": ",
retroarch_git_version,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, retroarch_git_version, sizeof(tmp));
if (menu_entries_append_enum(list, tmp, "", if (menu_entries_append_enum(list, tmp, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
count++; count++;
@ -1783,12 +1785,11 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
tmp2[0] = '\0'; tmp2[0] = '\0';
fill_pathname_join_concat_noext( strlcpy(tmp,
tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_IDENTIFIER), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_IDENTIFIER),
": ",
frontend->ident,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, frontend->ident, sizeof(tmp));
if (menu_entries_append_enum(list, tmp, "", if (menu_entries_append_enum(list, tmp, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
@ -1798,11 +1799,12 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
{ {
frontend->get_lakka_version(tmp2, sizeof(tmp2)); frontend->get_lakka_version(tmp2, sizeof(tmp2));
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION),
": ",
tmp2,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, tmp2, sizeof(tmp));
if (menu_entries_append_enum(list, tmp, "", if (menu_entries_append_enum(list, tmp, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
@ -1813,11 +1815,11 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
{ {
frontend->get_name(tmp2, sizeof(tmp2)); frontend->get_name(tmp2, sizeof(tmp2));
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME),
": ",
tmp2,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, tmp2, sizeof(tmp));
if (menu_entries_append_enum(list, tmp, "", if (menu_entries_append_enum(list, tmp, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
@ -1926,12 +1928,12 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
break; break;
} }
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE), MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE),
": ",
tmp2,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, tmp2, sizeof(tmp));
if (menu_entries_append_enum(list, tmp, "", if (menu_entries_append_enum(list, tmp, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
@ -1943,10 +1945,14 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
video_context_driver_get_ident(&ident_info); video_context_driver_get_ident(&ident_info);
tmp_string = ident_info.ident; tmp_string = ident_info.ident;
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER), MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER),
sizeof(tmp));
strlcat(tmp,
": ", ": ",
sizeof(tmp));
strlcat(tmp,
tmp_string ? tmp_string tmp_string ? tmp_string
: msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(tmp)); sizeof(tmp));
@ -2073,10 +2079,14 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
for (i = 0; i < ARRAY_SIZE(info_list); i++) for (i = 0; i < ARRAY_SIZE(info_list); i++)
{ {
fill_pathname_join_concat_noext(feat_str, strlcpy(feat_str,
msg_hash_to_str( msg_hash_to_str(
info_list[i].msg), info_list[i].msg),
sizeof(feat_str));
strlcat(feat_str,
": ", ": ",
sizeof(feat_str));
strlcat(feat_str,
info_list[i].enabled ? info_list[i].enabled ?
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES) :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO),
@ -2323,8 +2333,9 @@ static int create_string_list_rdb_entry_string(
string_list_join_concat(output_label, str_len, &str_list, "|"); string_list_join_concat(output_label, str_len, &str_list, "|");
string_list_deinitialize(&str_list); string_list_deinitialize(&str_list);
fill_pathname_join_concat_noext(tmp, desc, ": ", strlcpy(tmp, desc, sizeof(tmp));
actual_string, sizeof(tmp)); strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, actual_string, sizeof(tmp));
menu_entries_append_enum(list, tmp, output_label, menu_entries_append_enum(list, tmp, output_label,
enum_idx, enum_idx,
0, 0, 0); 0, 0, 0);
@ -2523,11 +2534,11 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->name) if (db_info_entry->name)
{ {
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME),
": ",
db_info_entry->name,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, db_info_entry->name, sizeof(tmp));
menu_entries_append_enum(info->list, tmp, menu_entries_append_enum(info->list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_NAME), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_NAME),
MENU_ENUM_LABEL_RDB_ENTRY_NAME, MENU_ENUM_LABEL_RDB_ENTRY_NAME,
@ -2536,11 +2547,11 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->description) if (db_info_entry->description)
{ {
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DESCRIPTION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DESCRIPTION),
": ",
db_info_entry->description,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, db_info_entry->description, sizeof(tmp));
menu_entries_append_enum(info->list, tmp, menu_entries_append_enum(info->list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION),
MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION, MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION,
@ -2549,11 +2560,11 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->genre) if (db_info_entry->genre)
{ {
fill_pathname_join_concat_noext(tmp, strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GENRE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GENRE),
": ",
db_info_entry->genre,
sizeof(tmp)); sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
strlcat(tmp, db_info_entry->genre, sizeof(tmp));
menu_entries_append_enum(info->list, tmp, menu_entries_append_enum(info->list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_GENRE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_GENRE),
MENU_ENUM_LABEL_RDB_ENTRY_GENRE, MENU_ENUM_LABEL_RDB_ENTRY_GENRE,

View File

@ -5492,10 +5492,14 @@ bool runloop_event_init_core(
if (!sys_info->info.library_version) if (!sys_info->info.library_version)
sys_info->info.library_version = "v0"; sys_info->info.library_version = "v0";
fill_pathname_join_concat_noext( strlcpy(
video_st->title_buf, video_st->title_buf,
msg_hash_to_str(MSG_PROGRAM), msg_hash_to_str(MSG_PROGRAM),
sizeof(video_st->title_buf));
strlcat(video_st->title_buf,
" ", " ",
sizeof(video_st->title_buf));
strlcat(video_st->title_buf,
sys_info->info.library_name, sys_info->info.library_name,
sizeof(video_st->title_buf)); sizeof(video_st->title_buf));
strlcat(video_st->title_buf, " ", strlcat(video_st->title_buf, " ",