diff options
author | Max Kellermann <max@duempel.org> | 2011-09-10 18:48:10 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-13 21:47:00 +0200 |
commit | a94d4be466ea3a48389361b483f72df45834f7d2 (patch) | |
tree | 734076ad49d963a00648f58dee4cde111dc0364a /src/database.c | |
parent | b7d2d4cfe8b88174a7b1f41840ddc0b23dbd6a75 (diff) | |
download | mpd-a94d4be466ea3a48389361b483f72df45834f7d2.tar.gz mpd-a94d4be466ea3a48389361b483f72df45834f7d2.tar.xz mpd-a94d4be466ea3a48389361b483f72df45834f7d2.zip |
db_plugin: add method visit()
Diffstat (limited to '')
-rw-r--r-- | src/database.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/database.c b/src/database.c index e3fa7442b..9c4d90a2b 100644 --- a/src/database.c +++ b/src/database.c @@ -21,6 +21,7 @@ #include "database.h" #include "db_error.h" #include "db_save.h" +#include "db_selection.h" #include "db_visitor.h" #include "db_plugin.h" #include "db/simple_db_plugin.h" @@ -108,9 +109,9 @@ db_get_song(const char *file) } bool -db_walk(const char *uri, - const struct db_visitor *visitor, void *ctx, - GError **error_r) +db_visit(const struct db_selection *selection, + const struct db_visitor *visitor, void *ctx, + GError **error_r) { if (db == NULL) { g_set_error_literal(error_r, db_quark(), DB_DISABLED, @@ -118,23 +119,18 @@ db_walk(const char *uri, return false; } - struct directory *directory = db_get_directory(uri); - if (directory == NULL) { - struct song *song; - if (visitor->song != NULL && - (song = db_get_song(uri)) != NULL) - return visitor->song(song, ctx, error_r); - - g_set_error(error_r, db_quark(), DB_NOT_FOUND, - "No such directory: %s", uri); - return false; - } + return db_plugin_visit(db, selection, visitor, ctx, error_r); +} - if (visitor->directory != NULL && - !visitor->directory(directory, ctx, error_r)) - return false; +bool +db_walk(const char *uri, + const struct db_visitor *visitor, void *ctx, + GError **error_r) +{ + struct db_selection selection; + db_selection_init(&selection, uri, true); - return directory_walk(directory, visitor, ctx, error_r); + return db_visit(&selection, visitor, ctx, error_r); } bool |