summaryrefslogtreecommitdiffstats
path: root/apps/playlist_catalog.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-05-25 07:13:13 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-05-25 07:13:13 +0000
commit2aa0791ff80bf757534fcfb1e918515704ae4173 (patch)
treeb173903d37c1267a2f5ec0c366de1cc6663303db /apps/playlist_catalog.c
parent69f4ffe6863f81f0fb16f6cd501379bfb2c62a16 (diff)
downloadrockbox-2aa0791ff80bf757534fcfb1e918515704ae4173.tar.gz
rockbox-2aa0791ff80bf757534fcfb1e918515704ae4173.tar.bz2
rockbox-2aa0791ff80bf757534fcfb1e918515704ae4173.zip
Fix part of FS#9032 - "create playlist" appends the playlist instead of overwriting it... not sure about the speed issue.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17628 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist_catalog.c')
-rw-r--r--apps/playlist_catalog.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index ac86f48109..c7458f8351 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -323,12 +323,19 @@ static int add_track_to_playlist(char* filename, void* context)
/* Add "sel" file into specified "playlist". How to insert depends on type
of file */
-static int add_to_playlist(const char* playlist, const char* sel, int sel_attr)
+static int add_to_playlist(const char* playlist, bool new_playlist,
+ const char* sel, int sel_attr)
{
int fd;
int result = -1;
+ int flags = O_CREAT|O_WRONLY;
- fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND);
+ if (new_playlist)
+ flags |= O_TRUNC;
+ else
+ flags |= O_APPEND;
+
+ fd = open(playlist, flags);
if(fd < 0)
return result;
@@ -452,7 +459,7 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
return false;
}
- if (add_to_playlist(playlist, sel, sel_attr) == 0)
+ if (add_to_playlist(playlist, new_playlist, sel, sel_attr) == 0)
{
strncpy(most_recent_playlist, playlist+playlist_dir_length+1,
sizeof(most_recent_playlist));