diff options
Diffstat (limited to 'src/playlist_save.c')
-rw-r--r-- | src/playlist_save.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/playlist_save.c b/src/playlist_save.c index 8ddc93ec9..6571e286c 100644 --- a/src/playlist_save.c +++ b/src/playlist_save.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2010 The Music Player Daemon Project + * Copyright (C) 2003-2011 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,9 @@ #include "config.h" #include "playlist_save.h" +#include "playlist.h" #include "stored_playlist.h" +#include "queue.h" #include "song.h" #include "mapper.h" #include "path.h" @@ -108,18 +110,24 @@ spl_save_playlist(const char *name_utf8, const struct playlist *playlist) return spl_save_queue(name_utf8, &playlist->queue); } -enum playlist_result -playlist_load_spl(struct playlist *playlist, const char *name_utf8) +bool +playlist_load_spl(struct playlist *playlist, struct player_control *pc, + const char *name_utf8, + unsigned start_index, unsigned end_index, + GError **error_r) { GPtrArray *list; - list = spl_load(name_utf8); + list = spl_load(name_utf8, error_r); if (list == NULL) - return PLAYLIST_RESULT_NO_SUCH_LIST; + return false; + + if (list->len < end_index) + end_index = list->len; - for (unsigned i = 0; i < list->len; ++i) { + for (unsigned i = start_index; i < end_index; ++i) { const char *temp = g_ptr_array_index(list, i); - if ((playlist_append_uri(playlist, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { + if ((playlist_append_uri(playlist, pc, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { /* for windows compatibility, convert slashes */ char *temp2 = g_strdup(temp); char *p = temp2; @@ -128,7 +136,7 @@ playlist_load_spl(struct playlist *playlist, const char *name_utf8) *p = '/'; p++; } - if ((playlist_append_uri(playlist, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { + if ((playlist_append_uri(playlist, pc, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { g_warning("can't add file \"%s\"", temp2); } g_free(temp2); @@ -136,5 +144,5 @@ playlist_load_spl(struct playlist *playlist, const char *name_utf8) } spl_free(list); - return PLAYLIST_RESULT_SUCCESS; + return true; } |