directory: don't visit "self" in _walk()

Let the caller decide if the current directory should be visited.
This commit is contained in:
Max Kellermann 2011-09-13 20:38:12 +02:00
parent 3fc6beeff0
commit 412cf974a4
2 changed files with 8 additions and 4 deletions

View File

@ -128,6 +128,10 @@ db_walk(const char *uri,
return false;
}
if (visitor->directory != NULL &&
!visitor->directory(directory, ctx, error_r))
return false;
return directory_walk(directory, visitor, ctx, error_r);
}

View File

@ -177,10 +177,6 @@ directory_walk(struct directory *directory,
assert(visitor != NULL);
assert(error_r == NULL || *error_r == NULL);
if (visitor->directory != NULL &&
!visitor->directory(directory, ctx, error_r))
return false;
if (visitor->song != NULL) {
struct songvec *sv = &directory->songs;
for (size_t i = 0; i < sv->nr; ++i)
@ -192,6 +188,10 @@ directory_walk(struct directory *directory,
for (size_t i = 0; i < dv->nr; ++i) {
struct directory *child = dv->base[i];
if (visitor->directory != NULL &&
!visitor->directory(child, ctx, error_r))
return false;
if (!directory_walk(child, visitor, ctx, error_r))
return false;
}