tagtree: Improve suggested playlist filename for "special entries"

Make the suggested playlist filename for special
entries such as "[Random]" or "[All Tracks]" a
bit more descriptive, by mentioning the current
table as well, e.g.:

"The Beatles [All Tracks].m3u8", instead of just
"[All Tracks].m3u8"

Change-Id: I43d9386c06081540cdcae715afc0b0351857633d
This commit is contained in:
Christian Soffke 2025-03-06 02:48:42 +01:00
parent 10b4cab793
commit 7693ecc2a2

View file

@ -923,8 +923,26 @@ static int dirbrowse(void)
else
{
attr = ATTR_DIRECTORY;
tagtree_get_entry_name(&tc, tc.selected_item,
buf, sizeof(buf));
int title_len = 0;
/* In case of "special entries", add table title as
prefix, e.g. "The Beatles [All Tracks]", instead
of just "[All Tracks]", to improve the suggested
playlist filename.
*/
if (tc.selected_item < tc.special_entry_count)
{
title_len = snprintf(buf, sizeof(buf), "%s ",
tagtree_get_title(&tc));
if (title_len < 0)
title_len = 0;
}
if (title_len < (int) sizeof(buf))
tagtree_get_entry_name(&tc, tc.selected_item,
buf + title_len,
sizeof(buf) - title_len);
fix_path_part(buf, 0, sizeof(buf) - 1);
}
}