diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist_catalog.c | 13 |
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) | |||
323 | 323 | ||
324 | /* Add "sel" file into specified "playlist". How to insert depends on type | 324 | /* Add "sel" file into specified "playlist". How to insert depends on type |
325 | of file */ | 325 | of file */ |
326 | static int add_to_playlist(const char* playlist, const char* sel, int sel_attr) | 326 | static int add_to_playlist(const char* playlist, bool new_playlist, |
327 | const char* sel, int sel_attr) | ||
327 | { | 328 | { |
328 | int fd; | 329 | int fd; |
329 | int result = -1; | 330 | int result = -1; |
331 | int flags = O_CREAT|O_WRONLY; | ||
330 | 332 | ||
331 | fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND); | 333 | if (new_playlist) |
334 | flags |= O_TRUNC; | ||
335 | else | ||
336 | flags |= O_APPEND; | ||
337 | |||
338 | fd = open(playlist, flags); | ||
332 | if(fd < 0) | 339 | if(fd < 0) |
333 | return result; | 340 | return result; |
334 | 341 | ||
@@ -452,7 +459,7 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr, | |||
452 | return false; | 459 | return false; |
453 | } | 460 | } |
454 | 461 | ||
455 | if (add_to_playlist(playlist, sel, sel_attr) == 0) | 462 | if (add_to_playlist(playlist, new_playlist, sel, sel_attr) == 0) |
456 | { | 463 | { |
457 | strncpy(most_recent_playlist, playlist+playlist_dir_length+1, | 464 | strncpy(most_recent_playlist, playlist+playlist_dir_length+1, |
458 | sizeof(most_recent_playlist)); | 465 | sizeof(most_recent_playlist)); |