From 0a6c5d7fa2f276b8e155d69bea17650bad46f089 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 18 Dec 2019 19:57:22 +0100 Subject: Split the libfstree add_by_path tree traversal function out Signed-off-by: David Oberhollenzer --- include/fstree.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/fstree.h b/include/fstree.h index 9d0d045..aff3952 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -172,6 +172,20 @@ void fstree_post_process(fstree_t *fs); */ char *fstree_get_path(tree_node_t *node); +/* + Resolve a path to a tree node. Returns NULL on failure and sets errno. + + If "create_implicitly" is set to true, the function acts essentially like + mkdir_p if part of the path doesn't exist yet. + + If "stop_at_parent" is true, the function stops at the last component and + returns the parent or would-be-parent of the last path component, but doesn't + check if the last path component exists or not. + */ +tree_node_t *fstree_get_node_by_path(fstree_t *fs, tree_node_t *root, + const char *path, bool create_implicitly, + bool stop_at_parent); + /* Convert back to forward slashed, remove all preceeding and trailing slashes, collapse all sequences of slashes, remove all path components that are '.' -- cgit v1.2.3