summaryrefslogtreecommitdiffstats
path: root/apps/playlist_catalog.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-08-17 23:40:45 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-08-18 10:18:31 -0500
commit8b7ae89b43ef4c96b55671759869397676ee9e05 (patch)
treefb40f9f121d6d73667221b08d9af558e02bcae74 /apps/playlist_catalog.c
parent5a4cdb96b91078c7cd3f8d5a389aace68b530437 (diff)
downloadrockbox-8b7ae89b43ef4c96b55671759869397676ee9e05.tar.gz
rockbox-8b7ae89b43ef4c96b55671759869397676ee9e05.tar.bz2
rockbox-8b7ae89b43ef4c96b55671759869397676ee9e05.zip
Playlist rework
consolidate some of the playlist create functions remove extensions from playlist naming (you can still add it if you desire) switch to strlcpy, strlcpy functions Change-Id: Ibd62912da4d1f68ed5366baa887d92d4c6b1f933
Diffstat (limited to 'apps/playlist_catalog.c')
-rw-r--r--apps/playlist_catalog.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 2147ea990c..7de907c8d0 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -326,7 +326,7 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
bool new_playlist, char *m3u8name)
{
int result;
- char playlist[MAX_PATH + 6];
+ char playlist[MAX_PATH + 7]; /* room for /.m3u8\0*/
if (in_add_to_playlist)
return false;
@@ -338,24 +338,32 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
size_t len;
if (m3u8name == NULL)
{
- /*If sel is a folder, we prefill the text field with its name*/
- const char *name = strrchr(sel, '/');
- snprintf(playlist, sizeof(playlist), "%s/%s.m3u8",
+ const char *name;
+ /* If sel is empty, root, or playlist directory we use 'all' */
+ if (!sel || !strcmp(sel, "/") || !strcmp(sel, playlist_dir))
+ {
+ if (!sel || !strcmp(sel, PLAYLIST_CATALOG_DEFAULT_DIR))
+ sel = "/";
+ name = "/all";
+ }
+ else /*If sel is a folder, we prefill the text field with its name*/
+ name = strrchr(sel, '/');
+
+ snprintf(playlist, MAX_PATH + 1, "%s/%s",
playlist_dir,
(name!=NULL && (sel_attr & ATTR_DIRECTORY))?name+1:"");
}
else
- strcpy(playlist, m3u8name);
+ strlcpy(playlist, m3u8name, MAX_PATH);
- len = strlen(playlist);
+ if (kbd_input(playlist, MAX_PATH))
+ return false;
+ len = strlen(playlist);
if(len > 4 && !strcasecmp(&playlist[len-4], ".m3u"))
- strcat(playlist, "8");
+ strlcat(playlist, "8", sizeof(playlist));
else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8"))
- strcat(playlist, ".m3u8");
-
- if (kbd_input(playlist, sizeof(playlist)))
- return false;
+ strlcat(playlist, ".m3u8", sizeof(playlist));
}
else
{