diff options
author | Max Kellermann <max@duempel.org> | 2014-02-26 19:48:37 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-26 19:50:46 +0100 |
commit | 69a42fc901d06af2f90d7046e153dc1273f19beb (patch) | |
tree | 672f869bd68f193343b98c10f5b946c031731410 /src/db/plugins/simple/SimpleDatabasePlugin.cxx | |
parent | 525789cd36c0dcf5a9b8a9fe25944197e9fc19cf (diff) | |
download | mpd-69a42fc901d06af2f90d7046e153dc1273f19beb.tar.gz mpd-69a42fc901d06af2f90d7046e153dc1273f19beb.tar.xz mpd-69a42fc901d06af2f90d7046e153dc1273f19beb.zip |
db/simple/Directory: LookupDirectory() return remaining URI
Code can now be reused in LookupSong().
Diffstat (limited to 'src/db/plugins/simple/SimpleDatabasePlugin.cxx')
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.cxx | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 9911caa66..8ba6eef92 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -244,28 +244,33 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, { ScopeDatabaseLock protect; - const Directory *directory = root->LookupDirectory(selection.uri.c_str()); - if (directory == nullptr) { + auto r = root->LookupDirectory(selection.uri.c_str()); + if (r.uri == nullptr) { + /* it's a directory */ + + if (selection.recursive && visit_directory && + !visit_directory(r.directory->Export(), error)) + return false; + + return r.directory->Walk(selection.recursive, selection.filter, + visit_directory, visit_song, + visit_playlist, + error); + } + + if (strchr(r.uri, '/') == nullptr) { if (visit_song) { - Song *song = root->LookupSong(selection.uri.c_str()); + Song *song = r.directory->FindSong(r.uri); if (song != nullptr) { const LightSong song2 = song->Export(); return !selection.Match(song2) || visit_song(song2, error); } } - - error.Set(db_domain, DB_NOT_FOUND, "No such directory"); - return false; } - if (selection.recursive && visit_directory && - !visit_directory(directory->Export(), error)) - return false; - - return directory->Walk(selection.recursive, selection.filter, - visit_directory, visit_song, visit_playlist, - error); + error.Set(db_domain, DB_NOT_FOUND, "No such directory"); + return false; } bool |