diff options
Diffstat (limited to 'src/Mapper.cxx')
-rw-r--r-- | src/Mapper.cxx | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Mapper.cxx b/src/Mapper.cxx index cbe45daa0..c6d8a3ea5 100644 --- a/src/Mapper.cxx +++ b/src/Mapper.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 @@ -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(); |