summaryrefslogtreecommitdiff
path: root/src/Mapper.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-14 22:09:02 +0200
committerMax Kellermann <max@duempel.org>2013-10-14 22:09:02 +0200
commit0b27ac2f5c6a352be733f00e873ceb9d0904e92a (patch)
treed0b5775b1e0afe08b4c4873ec8887f548d3e8fe0 /src/Mapper.cxx
parent6fd481df978ad4666780ef838e6c8540f6ea190f (diff)
fs/Path: add method RelativeFS()
Move code from map_fs_to_utf8().
Diffstat (limited to 'src/Mapper.cxx')
-rw-r--r--src/Mapper.cxx16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/Mapper.cxx b/src/Mapper.cxx
index c1e508b05..2ccc36961 100644
--- a/src/Mapper.cxx
+++ b/src/Mapper.cxx
@@ -251,17 +251,11 @@ map_song_fs(const Song *song)
std::string
map_fs_to_utf8(const char *path_fs)
{
- if (!music_dir_fs.IsNull() &&
- memcmp(path_fs, music_dir_fs.data(), music_dir_fs_length) == 0 &&
- G_IS_DIR_SEPARATOR(path_fs[music_dir_fs_length]))
- /* remove musicDir prefix */
- path_fs += music_dir_fs_length + 1;
- else if (G_IS_DIR_SEPARATOR(path_fs[0]))
- /* not within musicDir */
- return NULL;
-
- while (path_fs[0] == G_DIR_SEPARATOR)
- ++path_fs;
+ if (G_IS_DIR_SEPARATOR(path_fs[0])) {
+ path_fs = music_dir_fs.RelativeFS(path_fs);
+ if (path_fs == nullptr || *path_fs == 0)
+ return std::string();
+ }
return Path::ToUTF8(path_fs);
}