diff options
author | Max Kellermann <max@duempel.org> | 2014-02-07 00:29:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-07 00:42:14 +0100 |
commit | c13810ebaa7075284691eb2add089ba407dfd1ea (patch) | |
tree | 1ebeb2104ee4a3e73f49416267aec2e79943821b /src/db/DatabaseSong.cxx | |
parent | 19a982cf693e660ce296a29a9830f1e94d9f1b4c (diff) | |
download | mpd-c13810ebaa7075284691eb2add089ba407dfd1ea.tar.gz mpd-c13810ebaa7075284691eb2add089ba407dfd1ea.tar.xz mpd-c13810ebaa7075284691eb2add089ba407dfd1ea.zip |
Mapper: move map_song_detach() to db/DatabaseSong.cxx
Use Storage::MapUTF8() internally, don't use global variables.
Diffstat (limited to 'src/db/DatabaseSong.cxx')
-rw-r--r-- | src/db/DatabaseSong.cxx | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/db/DatabaseSong.cxx b/src/db/DatabaseSong.cxx index f6229194b..d9adad7a0 100644 --- a/src/db/DatabaseSong.cxx +++ b/src/db/DatabaseSong.cxx @@ -19,18 +19,35 @@ #include "config.h" #include "DatabaseSong.hxx" +#include "LightSong.hxx" #include "DatabasePlugin.hxx" #include "DetachedSong.hxx" -#include "Mapper.hxx" +#include "storage/StorageInterface.hxx" + +DetachedSong +DatabaseDetachSong(const Storage &storage, const LightSong &song) +{ + DetachedSong detached(song); + assert(detached.IsInDatabase()); + + if (!detached.HasRealURI()) { + const auto uri = song.GetURI(); + detached.SetRealURI(storage.MapUTF8(uri.c_str())); + } + + return detached; +} DetachedSong * -DatabaseDetachSong(const Database &db, const char *uri, Error &error) +DatabaseDetachSong(const Database &db, const Storage &storage, const char *uri, + Error &error) { const LightSong *tmp = db.GetSong(uri, error); if (tmp == nullptr) return nullptr; - DetachedSong *song = new DetachedSong(map_song_detach(*tmp)); + DetachedSong *song = new DetachedSong(DatabaseDetachSong(storage, + *tmp)); db.ReturnSong(tmp); return song; } |