diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2023-06-06 00:46:30 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2023-09-21 05:09:39 +0200 |
commit | 6ac55adc88cdacdc78e17b3e8c75fedc1d5972ef (patch) | |
tree | 24b09f6dbed164568166ec3a5064ae7584430ecb | |
parent | 8f3cb75df0955eef3a4413d077ce764dd40f4eba (diff) | |
download | rockbox-6ac55adc88.tar.gz rockbox-6ac55adc88.zip |
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
-rw-r--r-- | apps/menus/playlist_menu.c | 20 |
1 files changed, 17 insertions, 3 deletions
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 : |