DetachedSong: add attribute "real_uri"

Prepare for UPnP songs that retain there database identity.
This commit is contained in:
Max Kellermann
2014-01-18 18:20:54 +01:00
parent 483b1f51c9
commit 5d4b450c52
7 changed files with 62 additions and 11 deletions

View File

@@ -26,6 +26,7 @@
#include "Directory.hxx"
#include "Song.hxx"
#include "DetachedSong.hxx"
#include "LightSong.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/Charset.hxx"
@@ -220,7 +221,15 @@ map_detached_song_fs(const char *uri_utf8)
DetachedSong
map_song_detach(const LightSong &song)
{
return DetachedSong(song);
DetachedSong detached(song);
if (detached.IsInDatabase()) {
const auto uri = song.GetURI();
detached.SetRealURI(PathTraitsUTF8::Build(music_dir_utf8.c_str(),
uri.c_str()));
}
return detached;
}
AllocatedPath
@@ -235,7 +244,7 @@ AllocatedPath
map_song_fs(const DetachedSong &song)
{
if (song.IsAbsoluteFile())
return AllocatedPath::FromUTF8(song.GetURI());
return AllocatedPath::FromUTF8(song.GetRealURI());
else
return map_uri_fs(song.GetURI());
}