diff options
Diffstat (limited to '')
-rw-r--r-- | src/PlaylistSave.cxx (renamed from src/playlist_save.c) | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/playlist_save.c b/src/PlaylistSave.cxx index 334159e0d..745744490 100644 --- a/src/playlist_save.c +++ b/src/PlaylistSave.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,16 +18,18 @@ */ #include "config.h" -#include "playlist_save.h" -#include "playlist.h" -#include "stored_playlist.h" -#include "queue.h" +#include "PlaylistSave.hxx" +#include "PlaylistFile.hxx" +#include "Playlist.hxx" #include "song.h" -#include "mapper.h" +#include "Mapper.hxx" +#include "Idle.hxx" + +extern "C" { #include "path.h" #include "uri.h" -#include "database.h" -#include "idle.h" +} + #include "glib_compat.h" #include <glib.h> @@ -96,8 +98,8 @@ spl_save_queue(const char *name_utf8, const struct queue *queue) if (file == NULL) return PLAYLIST_RESULT_ERRNO; - for (unsigned i = 0; i < queue_length(queue); i++) - playlist_print_song(file, queue_get(queue, i)); + for (unsigned i = 0; i < queue->GetLength(); i++) + playlist_print_song(file, queue->Get(i)); fclose(file); @@ -117,34 +119,35 @@ playlist_load_spl(struct playlist *playlist, struct player_control *pc, unsigned start_index, unsigned end_index, GError **error_r) { - GPtrArray *list; - - list = spl_load(name_utf8, error_r); - if (list == NULL) + GError *error = NULL; + PlaylistFileContents contents = LoadPlaylistFile(name_utf8, &error); + if (contents.empty() && error != nullptr) { + g_propagate_error(error_r, error); return false; + } - if (list->len < end_index) - end_index = list->len; + if (end_index > contents.size()) + end_index = contents.size(); for (unsigned i = start_index; i < end_index; ++i) { - const char *temp = g_ptr_array_index(list, i); - if ((playlist_append_uri(playlist, pc, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { + const auto &uri_utf8 = contents[i]; + + if ((playlist->AppendURI(*pc, uri_utf8.c_str())) != PLAYLIST_RESULT_SUCCESS) { /* for windows compatibility, convert slashes */ - char *temp2 = g_strdup(temp); + char *temp2 = g_strdup(uri_utf8.c_str()); char *p = temp2; while (*p) { if (*p == '\\') *p = '/'; p++; } - if ((playlist_append_uri(playlist, pc, temp2, - NULL)) != PLAYLIST_RESULT_SUCCESS) { + + if (playlist->AppendURI(*pc, temp2) != PLAYLIST_RESULT_SUCCESS) g_warning("can't add file \"%s\"", temp2); - } + g_free(temp2); } } - spl_free(list); return true; } |