diff options
Diffstat (limited to '')
-rw-r--r-- | src/PlaylistSave.cxx (renamed from src/playlist_save.c) | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/playlist_save.c b/src/PlaylistSave.cxx index 122eca332..8d1908aac 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-2012 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 "song.h" + +extern "C" { +#include "playlist.h" #include "mapper.h" #include "path.h" #include "uri.h" -#include "database.h" #include "idle.h" +} + #include "glib_compat.h" #include <glib.h> @@ -117,33 +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_append_uri(playlist, pc, uri_utf8.c_str(), + nullptr)) != 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, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { + if ((playlist_append_uri(playlist, pc, temp2, NULL)) != PLAYLIST_RESULT_SUCCESS) { g_warning("can't add file \"%s\"", temp2); } g_free(temp2); } } - spl_free(list); return true; } |