From 6ac55adc88cdacdc78e17b3e8c75fedc1d5972ef Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Tue, 6 Jun 2023 00:46:30 +0200 Subject: 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 --- apps/menus/playlist_menu.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index 0983f9c338..49ff56795a 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -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 : -- cgit v1.2.3