aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-13 21:24:22 +0200
committerMax Kellermann <max@duempel.org>2011-09-13 22:09:37 +0200
commita236a439cc84035a70c3f43fd926d39b9d8caaf7 (patch)
tree846667477e41ad2b53897b90c61c1f9d3363b428 /src/command.c
parentc779e2674abbc3eed08e49296c188a9f9ed5270e (diff)
downloadmpd-a236a439cc84035a70c3f43fd926d39b9d8caaf7.tar.gz
mpd-a236a439cc84035a70c3f43fd926d39b9d8caaf7.tar.xz
mpd-a236a439cc84035a70c3f43fd926d39b9d8caaf7.zip
db_print: move code to function db_selection_print()
Use it in handle_lsinfo(), and eliminate some duplicate code.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/command.c b/src/command.c
index 13b3d4ca0..eb2b9ae4f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -30,7 +30,6 @@
#include "uri.h"
#include "decoder_print.h"
#include "directory.h"
-#include "directory_print.h"
#include "database.h"
#include "update.h"
#include "volume.h"
@@ -45,6 +44,7 @@
#include "dbUtils.h"
#include "db_error.h"
#include "db_print.h"
+#include "db_selection.h"
#include "tag.h"
#include "client.h"
#include "client_idle.h"
@@ -840,7 +840,6 @@ static enum command_return
handle_lsinfo(struct client *client, int argc, char *argv[])
{
const char *uri;
- const struct directory *directory;
if (argc == 2)
uri = argv[1];
@@ -848,14 +847,12 @@ handle_lsinfo(struct client *client, int argc, char *argv[])
/* default is root directory */
uri = "";
- directory = db_get_directory(uri);
- if (directory == NULL) {
- command_error(client, ACK_ERROR_NO_EXIST,
- "directory not found");
- return COMMAND_RETURN_ERROR;
- }
+ struct db_selection selection;
+ db_selection_init(&selection, uri, false);
- directory_print(client, directory);
+ GError *error = NULL;
+ if (!db_selection_print(client, &selection, true, &error))
+ return print_error(client, error);
if (isRootDirectory(uri)) {
GPtrArray *list = spl_list(NULL);