summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-06-06 00:46:30 +0200
committerChristian Soffke <christian.soffke@gmail.com>2023-09-21 05:09:39 +0200
commit6ac55adc88cdacdc78e17b3e8c75fedc1d5972ef (patch)
tree24b09f6dbed164568166ec3a5064ae7584430ecb
parent8f3cb75df0955eef3a4413d077ce764dd40f4eba (diff)
downloadrockbox-6ac55adc88cdacdc78e17b3e8c75fedc1d5972ef.tar.gz
rockbox-6ac55adc88cdacdc78e17b3e8c75fedc1d5972ef.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.c20
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)
51 uint32_t resume_elapsed; 51 uint32_t resume_elapsed;
52 uint32_t resume_offset; 52 uint32_t resume_offset;
53 53
54 char temp[MAX_PATH+1], *dot; 54 char temp[MAX_PATH+1], *p;
55 int len; 55 int len;
56 56
57 playlist_get_name(playlist, temp, sizeof(temp)-1); 57 playlist_get_name(playlist, temp, sizeof(temp)-1);
58 58
59 len = strlen(temp); 59 len = strlen(temp);
60 dot = strrchr(temp, '.');
61 60
62 if (!dot && len <= 1) 61 if (len <= 1) /* root or dynamic playlist */
63 { 62 {
64 catalog_get_directory(temp, sizeof(temp)); 63 catalog_get_directory(temp, sizeof(temp));
65 strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp)); 64 strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp));
66 } 65 }
66 else if (!strcmp((temp + len - 1), "/")) /* dir playlists other than root */
67 {
68 temp[len - 1] = '\0';
69 catalog_get_directory(directoryonly, sizeof(directoryonly));
70
71 if ((p = strrchr(temp, '/'))) /* use last path component as playlist name */
72 {
73 strlcat(directoryonly, p, sizeof(directoryonly));
74 strlcat(directoryonly, ".m3u8", sizeof(directoryonly));
75 }
76 else
77 strlcat(directoryonly, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(directoryonly));
78
79 strmemccpy(temp, directoryonly, sizeof(temp));
80 }
67 81
68 if (catalog_pick_new_playlist_name(temp, sizeof(temp), 82 if (catalog_pick_new_playlist_name(temp, sizeof(temp),
69 playlist ? playlist->filename : 83 playlist ? playlist->filename :