From 53c2215ab3175a99224e172e82422782431b2938 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Thu, 10 Jan 2008 22:10:11 +0100 Subject: [PATCH] Add function to get the parent of a given node. --- src/libisofs.h | 12 ++++++++++++ src/node.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/libisofs.h b/src/libisofs.h index 36b1aed..08de535 100644 --- a/src/libisofs.h +++ b/src/libisofs.h @@ -836,6 +836,18 @@ int iso_node_take(IsoNode *node); */ int iso_node_remove(IsoNode *node); +/* + * Get the parent of the given iso tree node. No extra ref is added to the + * returned directory, you must take your ref. with iso_node_ref() if you + * need it. + * + * If node is the root node, the same node will be returned as its parent. + * + * This returns NULL if the node doesn't pertain to any tree + * (it was removed/take). + */ +IsoDir *iso_node_get_parent(IsoNode *node); + /** * Get an iterator for the children of the given dir. * diff --git a/src/node.c b/src/node.c index 78b0c81..0628f49 100644 --- a/src/node.c +++ b/src/node.c @@ -489,6 +489,21 @@ int iso_node_remove(IsoNode *node) return ret; } +/* + * Get the parent of the given iso tree node. No extra ref is added to the + * returned directory, you must take your ref. with iso_node_ref() if you + * need it. + * + * If node is the root node, the same node will be returned as its parent. + * + * This returns NULL if the node doesn't pertain to any tree + * (it was removed/take). + */ +IsoDir *iso_node_get_parent(IsoNode *node) +{ + return node->parent; +} + /* TODO #00005 optimize iso_dir_iter_take */ int iso_dir_iter_take(IsoDirIter *iter) {