From 1b832b6dfb8d9da2b94f07ccc95c03614b378786 Mon Sep 17 00:00:00 2001
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Date: Fri, 21 Apr 2023 23:02:32 +0200
Subject: libutil: Add a stacked, recursive directory tree iterator

The concept is simple: Use the existing, platform dependent iterator
to walk a directory. If a directory entry is encountered, recurse into
it using the open_subdir handler, reconstruct the full path for any
entries discovered using the directory stack.

An additional function is added to skip a sub-hierarchy.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 include/util/dir_tree_iterator.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 include/util/dir_tree_iterator.h

(limited to 'include')

diff --git a/include/util/dir_tree_iterator.h b/include/util/dir_tree_iterator.h
new file mode 100644
index 0000000..953459f
--- /dev/null
+++ b/include/util/dir_tree_iterator.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/*
+ * dir_tree_iterator.h
+ *
+ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef UTIL_DIR_TREE_ITERATOR_H
+#define UTIL_DIR_TREE_ITERATOR_H
+
+#include "util/dir_iterator.h"
+
+dir_iterator_t *dir_tree_iterator_create(const char *path);
+
+void dir_tree_iterator_skip(dir_iterator_t *it);
+
+#endif /* UTIL_DIR_TREE_ITERATOR_H */
-- 
cgit v1.2.3