aboutsummaryrefslogtreecommitdiffstats
path: root/src/dirvec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dirvec.c')
-rw-r--r--src/dirvec.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dirvec.c b/src/dirvec.c
index 61e5a859a..7493a4d2c 100644
--- a/src/dirvec.c
+++ b/src/dirvec.c
@@ -78,3 +78,19 @@ void dirvec_destroy(struct dirvec *dv)
}
dv->nr = 0;
}
+
+int dirvec_for_each(const struct dirvec *dv,
+ int (*fn)(struct directory *, void *), void *arg)
+{
+ size_t i;
+
+ for (i = 0; i < dv->nr; ++i) {
+ struct directory *dir = dv->base[i];
+
+ assert(dir);
+ if (fn(dir, arg) < 0)
+ return -1;
+ }
+
+ return 0;
+}