aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:48:37 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:48:37 +0200
commitf320c9fa1dc2268fbd97ba9cb00140276c0a2e23 (patch)
treebd4102bc4a1d6914777305bf73690f3a8c5c7fa0 /src/command.c
parent528be8a0a9b8f9978b3968ab855e69a7ec2935d4 (diff)
downloadmpd-f320c9fa1dc2268fbd97ba9cb00140276c0a2e23.tar.gz
mpd-f320c9fa1dc2268fbd97ba9cb00140276c0a2e23.tar.xz
mpd-f320c9fa1dc2268fbd97ba9cb00140276c0a2e23.zip
directory: don't pass fd to traverseAllIn()
This patch continues the work of the previous patch: don't pass a file descriptor at all to traverseAllIn(). Since this fd was only used to report "directory not found" errors, we can easily move that check to the caller. This is a great relief, since it removes the dependency on a client connection from a lot of enumeration functions.
Diffstat (limited to '')
-rw-r--r--src/command.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/command.c b/src/command.c
index a11978a6c..238761f74 100644
--- a/src/command.c
+++ b/src/command.c
@@ -442,7 +442,13 @@ static int handleAdd(int fd, mpd_unused int *permission,
if (isRemoteUrl(path))
return addToPlaylist(path, NULL);
- result = addAllIn(fd, path);
+ result = addAllIn(path);
+ if (result == (enum playlist_result)-1) {
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
+ return -1;
+ }
+
return print_playlist_result(fd, result);
}
@@ -658,6 +664,9 @@ static int handleFind(int fd, mpd_unused int *permission,
}
ret = findSongsIn(fd, NULL, numItems, items);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
freeLocateTagItemArray(numItems, items);
@@ -680,6 +689,9 @@ static int handleSearch(int fd, mpd_unused int *permission,
}
ret = searchForSongsIn(fd, NULL, numItems, items);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
freeLocateTagItemArray(numItems, items);
@@ -702,6 +714,9 @@ static int handleCount(int fd, mpd_unused int *permission,
}
ret = searchStatsForSongsIn(fd, NULL, numItems, items);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
freeLocateTagItemArray(numItems, items);
@@ -840,10 +855,17 @@ static int handleListAll(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[])
{
char *directory = NULL;
+ int ret;
if (argc == 2)
directory = argv[1];
- return printAllIn(fd, directory);
+
+ ret = printAllIn(fd, directory);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
+
+ return ret;
}
static int handleVolume(int fd, mpd_unused int *permission,
@@ -962,6 +984,10 @@ static int handleList(int fd, mpd_unused int *permission,
if (conditionals)
freeLocateTagItemArray(numConditionals, conditionals);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
+
return ret;
}
@@ -1055,10 +1081,16 @@ static int handleListAllInfo(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[])
{
char *directory = NULL;
+ int ret;
if (argc == 2)
directory = argv[1];
- return printInfoForAllIn(fd, directory);
+ ret = printInfoForAllIn(fd, directory);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
+
+ return ret;
}
static int handlePing(mpd_unused int fd, mpd_unused int *permission,
@@ -1175,7 +1207,14 @@ static int handlePlaylistAdd(int fd, mpd_unused int *permission,
if (isRemoteUrl(path))
result = addToStoredPlaylist(path, playlist);
else
- result = addAllInToStoredPlaylist(fd, path, playlist);
+ result = addAllInToStoredPlaylist(path, playlist);
+
+ if (result == (enum playlist_result)-1) {
+ commandError(fd, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
+ return -1;
+ }
+
return print_playlist_result(fd, result);
}