Fix suggested file name when saving dirplay playlist

The suggested name was identical to the complete path
of the played folder, with a slash at the end, which,
if accepted, resulted in a file called only ".m3u8"
being saved there.

In case the path contained one or more dots, the string
was also stripped of the last dot and all chars following it.

Use Playlist Catalogue as the destination folder instead,
and pick last path component as the file name.

Change-Id: Ia2b7f7ebca746613d650bbab6d7a62ca1106efc6
This commit is contained in:
Christian Soffke 2023-06-06 00:46:30 +02:00
parent 8f3cb75df0
commit 6ac55adc88

View file

@ -51,19 +51,33 @@ int save_playlist_screen(struct playlist_info* playlist)
uint32_t resume_elapsed;
uint32_t resume_offset;
char temp[MAX_PATH+1], *dot;
char temp[MAX_PATH+1], *p;
int len;
playlist_get_name(playlist, temp, sizeof(temp)-1);
len = strlen(temp);
dot = strrchr(temp, '.');
if (!dot && len <= 1)
if (len <= 1) /* root or dynamic playlist */
{
catalog_get_directory(temp, sizeof(temp));
strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp));
}
else if (!strcmp((temp + len - 1), "/")) /* dir playlists other than root */
{
temp[len - 1] = '\0';
catalog_get_directory(directoryonly, sizeof(directoryonly));
if ((p = strrchr(temp, '/'))) /* use last path component as playlist name */
{
strlcat(directoryonly, p, sizeof(directoryonly));
strlcat(directoryonly, ".m3u8", sizeof(directoryonly));
}
else
strlcat(directoryonly, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(directoryonly));
strmemccpy(temp, directoryonly, sizeof(temp));
}
if (catalog_pick_new_playlist_name(temp, sizeof(temp),
playlist ? playlist->filename :