diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-08-17 23:40:45 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-08-18 10:18:31 -0500 |
commit | 8b7ae89b43ef4c96b55671759869397676ee9e05 (patch) | |
tree | fb40f9f121d6d73667221b08d9af558e02bcae74 /apps/menus | |
parent | 5a4cdb96b91078c7cd3f8d5a389aace68b530437 (diff) |
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/menus')
-rw-r--r-- | apps/menus/playlist_menu.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index 2de73415b2..c0a0d48d45 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -42,25 +42,30 @@ int save_playlist_screen(struct playlist_info* playlist) { char temp[MAX_PATH+1], *dot; int len; - + playlist_get_name(playlist, temp, sizeof(temp)-1); - len = strlen(temp); + len = strlen(temp); dot = strrchr(temp, '.'); - if (!dot) + + if (!dot && len <= 1) { - /* folder of some type */ - if (len > 1) - strcpy(&temp[len-1], ".m3u8"); - else - snprintf(temp, sizeof(temp), "%s%s", - catalog_get_directory(), DEFAULT_DYNAMIC_PLAYLIST_NAME); + snprintf(temp, sizeof(temp), "%s%s", + catalog_get_directory(), DEFAULT_DYNAMIC_PLAYLIST_NAME); } - else if (len > 4 && !strcasecmp(dot, ".m3u")) - strcat(temp, "8"); + + dot = strrchr(temp, '.'); + if (dot) /* remove extension */ + *dot = '\0'; if (!kbd_input(temp, sizeof(temp))) { + len = strlen(temp); + if(len > 4 && !strcasecmp(&temp[len-4], ".m3u")) + strlcat(temp, "8", sizeof(temp)); + else if(len <= 5 || strcasecmp(&temp[len-5], ".m3u8")) + strlcat(temp, ".m3u8", sizeof(temp)); + playlist_save(playlist, temp, NULL, 0); /* reload in case playlist was saved to cwd */ |