Add function to create a new root.
This commit is contained in:
parent
79c37ff193
commit
0c03ad051b
15
src/node.c
15
src/node.c
@ -12,6 +12,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
@ -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_*/
|
||||
|
Loading…
Reference in New Issue
Block a user