From 3946cf086183f8dd4d5d115f52ba1b87560b7ce4 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 4 Jul 2022 20:01:59 +0200 Subject: Move sqfs_tree_node_get_path to libsquashfs Signed-off-by: David Oberhollenzer --- include/sqfs/dir_reader.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/sqfs') diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h index c528e33..3ae4ca4 100644 --- a/include/sqfs/dir_reader.h +++ b/include/sqfs/dir_reader.h @@ -384,6 +384,27 @@ SQFS_API int sqfs_dir_reader_get_full_hierarchy(sqfs_dir_reader_t *rd, */ SQFS_API void sqfs_dir_tree_destroy(sqfs_tree_node_t *root); +/** + * @brief Recursively destroy a tree of @ref sqfs_tree_node_t nodes + * + * @memberof sqfs_tree_node_t + * + * This function can be used to assemble an absolute path from a tree + * node returned by @ref sqfs_dir_reader_get_full_hierarchy. + * + * The function recursively walks up the tree to assemble a path string. It + * returns "/" for the root node and assembles paths beginning with "/" for + * non-root nodes. The resulting path is slash separated, but (except for + * the root) never ends with a slash. + * + * The returned string needs to be free'd with @ref sqfs_free. + * + * @param node A pointer to a tree node. + * + * @return A pointer to a string on success, NULL on allocation failure. + */ +SQFS_API char *sqfs_tree_node_get_path(const sqfs_tree_node_t *node); + #ifdef __cplusplus } #endif -- cgit v1.2.3