diff options
author | Max Kellermann <max@duempel.org> | 2008-10-14 11:10:49 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-14 11:10:49 +0200 |
commit | 5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6 (patch) | |
tree | 5fd2efeb95e3412ac177434611770ca864325c0e /src/storedPlaylist.c | |
parent | a52a9fc1fc2b385dd66edd45f602ac337399cc83 (diff) | |
download | mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.tar.gz mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.tar.xz mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.zip |
mapper: new song-to-filesystem mapper library
The mapper library maps directory and song objects to file system
paths. With this central library, the code mixture in path.c should
be cleaned up, and we will be able to add neat features like aliasing.
Diffstat (limited to 'src/storedPlaylist.c')
-rw-r--r-- | src/storedPlaylist.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c index 4e20a6de4..3d5b8286f 100644 --- a/src/storedPlaylist.c +++ b/src/storedPlaylist.c @@ -19,6 +19,7 @@ #include "storedPlaylist.h" #include "playlist_save.h" #include "song.h" +#include "mapper.h" #include "path.h" #include "utils.h" #include "ls.h" @@ -91,7 +92,6 @@ List *loadStoredPlaylist(const char *utf8path) FILE *file; char buffer[MPD_PATH_MAX]; char path_max_tmp[MPD_PATH_MAX]; - const size_t musicDir_len = strlen(musicDir); if (!is_valid_playlist_name(utf8path)) return NULL; @@ -105,19 +105,27 @@ List *loadStoredPlaylist(const char *utf8path) while (myFgets(buffer, sizeof(buffer), file)) { char *s = buffer; - struct song *song; + const char *path_utf8; if (*s == PLAYLIST_COMMENT) continue; - if (s[musicDir_len] == '/' && - !strncmp(s, musicDir, musicDir_len)) - memmove(s, s + musicDir_len + 1, - strlen(s + musicDir_len + 1) + 1); - if ((song = db_get_song(s))) { + + if (isValidRemoteUtf8Url(s)) + insertInListWithoutKey(list, xstrdup(s)); + else { + struct song *song; + + path_utf8 = map_fs_to_utf8(s, path_max_tmp); + if (path_utf8 == NULL) + continue; + + song = db_get_song(path_utf8); + if (song == NULL) + continue; + song_get_url(song, path_max_tmp); insertInListWithoutKey(list, xstrdup(path_max_tmp)); - } else if (isValidRemoteUtf8Url(s)) - insertInListWithoutKey(list, xstrdup(s)); + } if (list->numberOfNodes >= playlist_max_length) break; |