Make playlist catalog and playlist save screen handle .m3u/.m3u8 better. Also fix a possible null-pointer case in the playlist save screen.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11654 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Magnus Holmgren 2006-12-03 20:45:12 +00:00
parent ec14b0f989
commit dc956ce993
2 changed files with 16 additions and 10 deletions

View file

@ -453,13 +453,17 @@ bool catalog_add_to_a_playlist(char* sel, int sel_attr, bool new_playlist)
if (new_playlist)
{
size_t len;
snprintf(playlist, MAX_PATH, "%s/", playlist_dir);
if (kbd_input(playlist, MAX_PATH))
return false;
if(strlen(playlist) <= 4 ||
strcasecmp(&playlist[strlen(playlist)-4], ".m3u"))
strcat(playlist, ".m3u");
len = strlen(playlist);
if(len > 4 && !strcasecmp(&playlist[len-4], ".m3u"))
strcat(playlist, "8");
else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8"))
strcat(playlist, ".m3u8");
}
else
{

View file

@ -79,19 +79,21 @@ bool playlist_menu(void)
int save_playlist_screen(struct playlist_info* playlist)
{
char* filename;
char temp[MAX_PATH+1];
int len;
filename = playlist_get_name(playlist, temp, sizeof(temp));
playlist_get_name(playlist, temp, sizeof(temp));
len = strlen(temp);
if (!filename || (len=strlen(filename)) <= 5 ||
strcasecmp(&filename[len-5], ".m3u8"))
strcpy(filename, DEFAULT_DYNAMIC_PLAYLIST_NAME);
if (len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
strcat(temp, "8");
if (len <= 5 || strcasecmp(&temp[len-5], ".m3u8"))
strcpy(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME);
if (!kbd_input(filename, sizeof(temp)))
if (!kbd_input(temp, sizeof(temp)))
{
playlist_save(playlist, filename);
playlist_save(playlist, temp);
/* reload in case playlist was saved to cwd */
reload_directory();