aboutsummaryrefslogtreecommitdiff
path: root/include/fstree.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-02-19 00:55:11 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-02-19 17:34:47 +0100
commit94269ff3c0166474c018c4973c481b2fcff00080 (patch)
tree7b5f38702fa4865599a6a3107071728580b99d05 /include/fstree.h
parentd9549b3d288a9cb053ab5198f3bc2d277b72600f (diff)
libfstree: Add a filter callback to the directory scanning function
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/fstree.h')
-rw-r--r--include/fstree.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/fstree.h b/include/fstree.h
index e5fc966..35d6778 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -41,6 +41,15 @@ typedef struct file_info_t file_info_t;
typedef struct dir_info_t dir_info_t;
typedef struct fstree_t fstree_t;
+/*
+ Optionally used by fstree_from_dir and fstree_from_subdir to
+ execute custom actions for each discovered node.
+
+ If it returns a value > 0, the new node is discarded, if < 0, scanning is
+ aborted and returns a failure status.
+ */
+typedef int (*scan_node_callback)(void *user, fstree_t *fs, tree_node_t *node);
+
/* Additional meta data stored in a tree_node_t for regular files. */
struct file_info_t {
/* Linked list pointer for files in fstree_t */
@@ -252,7 +261,8 @@ int fstree_resolve_hard_link(fstree_t *fs, tree_node_t *node);
Returns 0 on success, prints to stderr on failure.
*/
int fstree_from_dir(fstree_t *fs, tree_node_t *root,
- const char *path, unsigned int flags);
+ const char *path, scan_node_callback cb, void *user,
+ unsigned int flags);
/*
Same as fstree_from_dir, but scans a sub-directory inside the specified path.
@@ -261,6 +271,6 @@ int fstree_from_dir(fstree_t *fs, tree_node_t *root,
*/
int fstree_from_subdir(fstree_t *fs, tree_node_t *root,
const char *path, const char *subdir,
- unsigned int flags);
+ scan_node_callback cb, void *user, unsigned int flags);
#endif /* FSTREE_H */