From 0c03ad051bc17043209c7e5dfa8e083c5d5138cf Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Sun, 2 Dec 2007 18:54:55 +0100 Subject: [PATCH] Add function to create a new root. --- src/node.c | 15 +++++++++++++++ src/node.h | 7 +++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/node.c b/src/node.c index e58bdda..1f1b678 100644 --- a/src/node.c +++ b/src/node.c @@ -12,6 +12,7 @@ #include #include +#include /** * Increments the reference counting of the given node. @@ -392,3 +393,17 @@ int iso_dir_iter_remove(IsoDirIter *iter) return iso_node_remove(pos); } +int iso_node_new_root(IsoDir **root) +{ + IsoDir *dir; + + dir = calloc(1, sizeof(IsoDir)); + if (dir == NULL) { + return ISO_MEM_ERROR; + } + dir->node.type = LIBISO_DIR; + dir->node.atime = dir->node.ctime = dir->node.mtime = time(NULL); + dir->node.mode = S_IFDIR | 0555; + *root = dir; + return ISO_SUCCESS; +} diff --git a/src/node.h b/src/node.h index a7e2cf3..6ec7373 100644 --- a/src/node.h +++ b/src/node.h @@ -73,11 +73,8 @@ struct Iso_Node IsoDir *parent; /**< parent node, NULL for root */ /* - * Pointers to the doubled linked list of children in a dir. - * It is a circular list where the last child points to the first - * and viceversa. + * Pointer to the linked list of children in a dir. */ - IsoNode *prev; IsoNode *next; }; @@ -118,4 +115,6 @@ struct Iso_Dir_Iter IsoNode *pos; }; +int iso_node_new_root(IsoDir **root); + #endif /*LIBISO_NODE_H_*/