From 7ca19736c9ab90811965207010f0071d9a4b9df4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 17 Oct 2008 17:53:43 +0200 Subject: [PATCH] command: expect "file:///" url for local files When adding a local file, clients have to use the "file" URI schema described in RFC 1738 3.10. By adding this schema to "urlhandlers", a client can detect whether this feature is available. --- src/command.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/command.c b/src/command.c index b4f001c85..844ce8e9a 100644 --- a/src/command.c +++ b/src/command.c @@ -290,6 +290,8 @@ static void addCommand(const char *name, static int handleUrlHandlers(struct client *client, mpd_unused int argc, mpd_unused char *argv[]) { + if (client_get_uid(client) > 0) + client_puts(client, "handler: file://\n"); return printRemoteUrlHandlers(client); } @@ -448,8 +450,8 @@ static int handleAdd(struct client *client, char *path = argv[1]; enum playlist_result result; - if (path[0] == '/' && path[1] != 0) { - result = playlist_append_file(path, client_get_uid(client), + if (strncmp(path, "file:///", 8) == 0) { + result = playlist_append_file(path + 7, client_get_uid(client), NULL); return print_playlist_result(client, result); } @@ -473,8 +475,9 @@ static int handleAddId(struct client *client, int added_id; enum playlist_result result; - if (argv[1][0] == '/') - result = playlist_append_file(argv[1], client_get_uid(client), + if (strncmp(argv[1], "file:///", 8) == 0) + result = playlist_append_file(argv[1] + 7, + client_get_uid(client), &added_id); else result = addToPlaylist(argv[1], &added_id);