playlist catalog: improve UTF-8 BOM handling. correct length of array passed to create_playlist_list.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24718 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-02-17 14:14:24 +00:00
parent f7ba156b27
commit 35fa12d85f

View file

@ -224,7 +224,7 @@ static int display_playlists(char* playlist, bool view)
char* playlists[MAX_PLAYLISTS]; char* playlists[MAX_PLAYLISTS];
struct gui_synclist playlist_lists; struct gui_synclist playlist_lists;
if (create_playlist_list(playlists, sizeof(playlists), if (create_playlist_list(playlists, MAX_PLAYLISTS,
&num_playlists) != 0) &num_playlists) != 0)
return -1; return -1;
@ -345,14 +345,12 @@ static int add_to_playlist(const char* playlist, bool new_playlist,
{ {
int fd; int fd;
int result = -1; int result = -1;
int flags = O_CREAT|O_WRONLY;
if (new_playlist) if (new_playlist)
flags |= O_TRUNC; fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC);
else else
flags |= O_APPEND; fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND);
fd = open(playlist, flags);
if(fd < 0) if(fd < 0)
return result; return result;
@ -374,7 +372,7 @@ static int add_to_playlist(const char* playlist, bool new_playlist,
if(strcasecmp(playlist, sel) == 0) if(strcasecmp(playlist, sel) == 0)
goto exit; goto exit;
f = open(sel, O_RDONLY); f = open_utf8(sel, O_RDONLY);
if (f < 0) if (f < 0)
goto exit; goto exit;