diff options
author | Max Kellermann <max@duempel.org> | 2008-09-07 13:48:37 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-09 01:11:26 -0700 |
commit | 7d7b69e576500522a011627d7937e255aa7c16c7 (patch) | |
tree | e94ef26cff7f3272707aca3a8da54bb0ea7723d3 /src/command.c | |
parent | dcc575a3a877e342e895df9fc99108028151cc6a (diff) | |
download | mpd-7d7b69e576500522a011627d7937e255aa7c16c7.tar.gz mpd-7d7b69e576500522a011627d7937e255aa7c16c7.tar.xz mpd-7d7b69e576500522a011627d7937e255aa7c16c7.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 'src/command.c')
-rw-r--r-- | src/command.c | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/src/command.c b/src/command.c index 59a99141a..7a2981e68 100644 --- a/src/command.c +++ b/src/command.c @@ -440,7 +440,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); } @@ -656,6 +662,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); @@ -678,6 +687,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); @@ -700,6 +712,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); @@ -838,10 +853,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, @@ -960,6 +982,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; } @@ -1053,10 +1079,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, @@ -1173,7 +1205,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); } |