diff options
Diffstat (limited to 'src/PlaylistFile.cxx')
-rw-r--r-- | src/PlaylistFile.cxx | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index e7dae6258..2707bcb76 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -22,11 +22,10 @@ #include "PlaylistSave.hxx" #include "PlaylistInfo.hxx" #include "PlaylistVector.hxx" -#include "DatabasePlugin.hxx" -#include "DatabaseGlue.hxx" -#include "Song.hxx" +#include "DatabaseSong.hxx" +#include "DetachedSong.hxx" #include "Mapper.hxx" -#include "TextFile.hxx" +#include "fs/TextFile.hxx" #include "ConfigGlobal.hxx" #include "ConfigOption.hxx" #include "ConfigDefaults.hxx" @@ -43,10 +42,7 @@ #include <glib.h> #include <assert.h> -#include <sys/types.h> #include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> #include <string.h> #include <errno.h> @@ -159,10 +155,9 @@ LoadPlaylistFileInfo(PlaylistInfo &info, if (!StatFile(path_fs, st) || !S_ISREG(st.st_mode)) return false; - char *name = g_strndup(name_fs_str, - name_length + 1 - sizeof(PLAYLIST_FILE_SUFFIX)); - std::string name_utf8 = PathToUTF8(name); - g_free(name); + std::string name(name_fs_str, + name_length + 1 - sizeof(PLAYLIST_FILE_SUFFIX)); + std::string name_utf8 = PathToUTF8(name.c_str()); if (name_utf8.empty()) return false; @@ -250,7 +245,7 @@ LoadPlaylistFile(const char *utf8path, Error &error) if (!uri_has_scheme(s)) { uri_utf8 = map_fs_to_utf8(s); if (uri_utf8.empty()) { - if (PathTraits::IsAbsoluteFS(s)) { + if (PathTraitsFS::IsAbsolute(s)) { uri_utf8 = PathToUTF8(s); if (uri_utf8.empty()) continue; @@ -365,7 +360,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error) } bool -spl_append_song(const char *utf8path, const Song &song, Error &error) +spl_append_song(const char *utf8path, const DetachedSong &song, Error &error) { if (spl_map(error).IsNull()) return false; @@ -406,21 +401,15 @@ bool spl_append_uri(const char *url, const char *utf8file, Error &error) { if (uri_has_scheme(url)) { - Song *song = Song::NewRemote(url); - bool success = spl_append_song(utf8file, *song, error); - song->Free(); - return success; + return spl_append_song(utf8file, DetachedSong(url), + error); } else { - const Database *db = GetDatabase(error); - if (db == nullptr) - return false; - - Song *song = db->GetSong(url, error); + DetachedSong *song = DatabaseDetachSong(url, error); if (song == nullptr) return false; bool success = spl_append_song(utf8file, *song, error); - db->ReturnSong(song); + delete song; return success; } } |