From cf38505d8fddbfee431936969e34b9d438243f31 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 26 Dec 2009 02:10:38 +0100 Subject: playlist_queue: load playlists from music directory Try the playlist directory first, and if that file does not exist, try the same relative path within the music directory. --- src/playlist_queue.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/playlist_queue.c b/src/playlist_queue.c index b840aa042..76ac64bad 100644 --- a/src/playlist_queue.c +++ b/src/playlist_queue.c @@ -122,6 +122,9 @@ playlist_open_path_into_queue(const char *path_fs, struct playlist *dest) return result; } +/** + * Load a playlist from the configured playlist directory. + */ static enum playlist_result playlist_open_local_into_queue(const char *uri, struct playlist *dest) { @@ -142,13 +145,42 @@ playlist_open_local_into_queue(const char *uri, struct playlist *dest) return result; } +/** + * Load a playlist from the configured music directory. + */ +static enum playlist_result +playlist_open_local_into_queue2(const char *uri, struct playlist *dest) +{ + char *path_fs; + enum playlist_result result; + + assert(uri_safe_local(uri)); + + path_fs = map_uri_fs(uri); + if (path_fs == NULL) + return PLAYLIST_RESULT_NO_SUCH_LIST; + + result = playlist_open_path_into_queue(path_fs, dest); + g_free(path_fs); + + return result; +} + enum playlist_result playlist_open_into_queue(const char *uri, struct playlist *dest) { if (uri_has_scheme(uri)) return playlist_open_remote_into_queue(uri, dest); - else if (spl_valid_name(uri)) - return playlist_open_local_into_queue(uri, dest); - else - return PLAYLIST_RESULT_NO_SUCH_LIST; + + if (spl_valid_name(uri)) { + enum playlist_result result = + playlist_open_local_into_queue(uri, dest); + if (result != PLAYLIST_RESULT_NO_SUCH_LIST) + return result; + } + + if (uri_safe_local(uri)) + return playlist_open_local_into_queue2(uri, dest); + + return PLAYLIST_RESULT_NO_SUCH_LIST; } -- cgit v1.2.3