diff options
Diffstat (limited to '')
-rw-r--r-- | src/Mapper.cxx (renamed from src/mapper.c) | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/mapper.c b/src/Mapper.cxx index 7db74b1af..4d863418b 100644 --- a/src/mapper.c +++ b/src/Mapper.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -22,10 +22,13 @@ */ #include "config.h" -#include "mapper.h" -#include "directory.h" +#include "Mapper.hxx" +#include "Directory.hxx" #include "song.h" + +extern "C" { #include "path.h" +} #include <glib.h> @@ -178,19 +181,19 @@ map_uri_fs(const char *uri) } char * -map_directory_fs(const struct directory *directory) +map_directory_fs(const Directory *directory) { assert(music_dir_utf8 != NULL); assert(music_dir_fs != NULL); - if (directory_is_root(directory)) + if (directory->IsRoot()) return g_strdup(music_dir_fs); - return map_uri_fs(directory_get_path(directory)); + return map_uri_fs(directory->GetPath()); } char * -map_directory_child_fs(const struct directory *directory, const char *name) +map_directory_child_fs(const Directory *directory, const char *name) { assert(music_dir_utf8 != NULL); assert(music_dir_fs != NULL); @@ -219,13 +222,32 @@ map_directory_child_fs(const struct directory *directory, const char *name) return path; } +/** + * Map a song object that was created by song_dup_detached(). It does + * not have a real parent directory, only the dummy object + * #detached_root. + */ +static char * +map_detached_song_fs(const char *uri_utf8) +{ + char *uri_fs = utf8_to_fs_charset(uri_utf8); + if (uri_fs == NULL) + return NULL; + + char *path = g_build_filename(music_dir_fs, uri_fs, NULL); + g_free(uri_fs); + return path; +} + char * map_song_fs(const struct song *song) { assert(song_is_file(song)); if (song_in_database(song)) - return map_directory_child_fs(song->parent, song->uri); + return song_is_detached(song) + ? map_detached_song_fs(song->uri) + : map_directory_child_fs(song->parent, song->uri); else return utf8_to_fs_charset(song->uri); } |