aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_queue.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-26 02:10:38 +0100
committerMax Kellermann <max@duempel.org>2009-12-27 14:17:26 +0100
commitcf38505d8fddbfee431936969e34b9d438243f31 (patch)
treec4b69d136d430fe3f77dad4a3221646405289b1a /src/playlist_queue.c
parentaf964e8929407c43e6c45c2bd3f1a0c534b2f0cc (diff)
downloadmpd-cf38505d8fddbfee431936969e34b9d438243f31.tar.gz
mpd-cf38505d8fddbfee431936969e34b9d438243f31.tar.xz
mpd-cf38505d8fddbfee431936969e34b9d438243f31.zip
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.
Diffstat (limited to 'src/playlist_queue.c')
-rw-r--r--src/playlist_queue.c40
1 files 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;
}