aboutsummaryrefslogtreecommitdiffstats
path: root/src/QueueCommands.cxx
diff options
context:
space:
mode:
authorDenis Krjuchkov <denis@crazydev.net>2013-05-05 15:42:29 +0600
committerDenis Krjuchkov <denis@crazydev.net>2013-05-06 23:36:36 +0600
commita688745bdc6db32e2cb7765c5d113958dcd49411 (patch)
tree4e0ba55771d6552ae02ff29af9c57a6a265bffcf /src/QueueCommands.cxx
parent459d824c50b3ef444f0b94cc60bcbec83addf801 (diff)
downloadmpd-a688745bdc6db32e2cb7765c5d113958dcd49411.tar.gz
mpd-a688745bdc6db32e2cb7765c5d113958dcd49411.tar.xz
mpd-a688745bdc6db32e2cb7765c5d113958dcd49411.zip
ClientFile: use Path and file system API, update usages accordingly
This commit also fixes incorrect passing of UTF-8 strings to client_allow_file
Diffstat (limited to '')
-rw-r--r--src/QueueCommands.cxx27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/QueueCommands.cxx b/src/QueueCommands.cxx
index aac6d5a51..210b1501a 100644
--- a/src/QueueCommands.cxx
+++ b/src/QueueCommands.cxx
@@ -32,6 +32,7 @@
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "util/UriUtil.hxx"
+#include "fs/Path.hxx"
#include <string.h>
@@ -42,13 +43,20 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
enum playlist_result result;
if (strncmp(uri, "file:///", 8) == 0) {
- const char *path = uri + 7;
+ const char *path_utf8 = uri + 7;
+ const Path path_fs = Path::FromUTF8(path_utf8);
+
+ if (path_fs.IsNull()) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "unsupported file name");
+ return COMMAND_RETURN_ERROR;
+ }
GError *error = NULL;
- if (!client_allow_file(client, path, &error))
+ if (!client_allow_file(client, path_fs, &error))
return print_error(client, error);
- result = client->partition.AppendFile(path);
+ result = client->partition.AppendFile(path_utf8);
return print_playlist_result(client, result);
}
@@ -78,13 +86,20 @@ handle_addid(Client *client, int argc, char *argv[])
enum playlist_result result;
if (strncmp(uri, "file:///", 8) == 0) {
- const char *path = uri + 7;
+ const char *path_utf8 = uri + 7;
+ const Path path_fs = Path::FromUTF8(path_utf8);
+
+ if (path_fs.IsNull()) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "unsupported file name");
+ return COMMAND_RETURN_ERROR;
+ }
GError *error = NULL;
- if (!client_allow_file(client, path, &error))
+ if (!client_allow_file(client, path_fs, &error))
return print_error(client, error);
- result = client->partition.AppendFile(path, &added_id);
+ result = client->partition.AppendFile(path_utf8, &added_id);
} else {
if (uri_has_scheme(uri) && !uri_supported_scheme(uri)) {
command_error(client, ACK_ERROR_NO_EXIST,