aboutsummaryrefslogtreecommitdiffstats
path: root/src/Mapper.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mapper.cxx23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Mapper.cxx b/src/Mapper.cxx
index cbe45daa0..6910b4983 100644
--- a/src/Mapper.cxx
+++ b/src/Mapper.cxx
@@ -25,6 +25,7 @@
#include "Mapper.hxx"
#include "Directory.hxx"
#include "Song.hxx"
+#include "DetachedSong.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/Charset.hxx"
@@ -36,9 +37,7 @@
#include <assert.h>
#include <string.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <errno.h>
-#include <dirent.h>
static constexpr Domain mapper_domain("mapper");
@@ -150,7 +149,7 @@ map_to_relative_path(const char *path_utf8)
return !music_dir_utf8.empty() &&
memcmp(path_utf8, music_dir_utf8.c_str(),
music_dir_utf8_length) == 0 &&
- PathTraits::IsSeparatorUTF8(path_utf8[music_dir_utf8_length])
+ PathTraitsUTF8::IsSeparator(path_utf8[music_dir_utf8_length])
? path_utf8 + music_dir_utf8_length + 1
: path_utf8;
}
@@ -221,20 +220,24 @@ map_detached_song_fs(const char *uri_utf8)
AllocatedPath
map_song_fs(const Song &song)
{
- assert(song.IsFile());
+ return song.parent == nullptr
+ ? map_detached_song_fs(song.uri)
+ : map_directory_child_fs(*song.parent, song.uri);
+}
- if (song.IsInDatabase())
- return song.IsDetached()
- ? map_detached_song_fs(song.uri)
- : map_directory_child_fs(*song.parent, song.uri);
+AllocatedPath
+map_song_fs(const DetachedSong &song)
+{
+ if (song.IsAbsoluteFile())
+ return AllocatedPath::FromUTF8(song.GetURI());
else
- return AllocatedPath::FromUTF8(song.uri);
+ return map_uri_fs(song.GetURI());
}
std::string
map_fs_to_utf8(const char *path_fs)
{
- if (PathTraits::IsSeparatorFS(path_fs[0])) {
+ if (PathTraitsFS::IsSeparator(path_fs[0])) {
path_fs = music_dir_fs.RelativeFS(path_fs);
if (path_fs == nullptr || *path_fs == 0)
return std::string();