From 70b9b871509a879742d1b3fc093e7a8cb92a4ea2 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Fri, 7 Dec 2007 22:25:31 +0100 Subject: [PATCH] Expose iso_node_get_type(). --- src/libisofs.h | 17 +++++++++++++++++ src/node.c | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/src/libisofs.h b/src/libisofs.h index 6b49f3b..6292bc6 100644 --- a/src/libisofs.h +++ b/src/libisofs.h @@ -22,6 +22,18 @@ typedef struct Iso_Dir_Iter IsoDirIter; /** * The type of an IsoNode. + * + * When an user gets an IsoNode from an image, (s)he can use + * iso_node_get_type() to get the current type of the node, and then + * cast to the appropriate subtype. For example: + * + * ... + * IsoNode *node; + * res = iso_dir_iter_next(iter, &node); + * if (res == 1 && iso_node_get_type(node) == LIBISO_DIR) { + * IsoDir *dir = (IsoDir *)node; + * ... + * } */ enum IsoNodeType { LIBISO_DIR, @@ -191,6 +203,11 @@ void iso_node_ref(IsoNode *node); */ void iso_node_unref(IsoNode *node); +/** + * Get the type of an IsoNode. + */ +enum IsoNodeType iso_node_get_type(IsoNode *node); + /** * Set the name of a node. Note that if the node is already added to a dir * this can fail if dir already contains a node with the new name. diff --git a/src/node.c b/src/node.c index d3f7298..6ebe999 100644 --- a/src/node.c +++ b/src/node.c @@ -63,6 +63,14 @@ void iso_node_unref(IsoNode *node) } } +/** + * Get the type of an IsoNode. + */ +enum IsoNodeType iso_node_get_type(IsoNode *node) +{ + return node->type; +} + /** * Set the name of a node. *