diff options
author | Max Kellermann <max@duempel.org> | 2012-08-15 22:44:21 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-08-15 23:07:24 +0200 |
commit | 916a02017333ac32b8058d3c397eeb4ec85b742b (patch) | |
tree | d68e24237cf924eb7c077407cb415968010e2cac /src/mapper.c | |
parent | c2e4fe983da690907316dac9cd1838fc713dec1b (diff) |
Song: add function song_dup_detached()
Initial support for "detached" songs that come from the database, but
are private copies.
Diffstat (limited to 'src/mapper.c')
-rw-r--r-- | src/mapper.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/mapper.c b/src/mapper.c index 7db74b1af..1f8a54b46 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -219,13 +219,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); } |