Added more files, mainly beginning of filesystem sources implementation.

This commit is contained in:
Vreixo Formoso
2007-11-24 16:58:36 +01:00
parent 9ee4e39899
commit 6c090c9a7b
10 changed files with 283 additions and 30 deletions

56
src/node.c Normal file
View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2007 Vreixo Formoso
*
* This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. See COPYING file for details.
*/
#include "node.h"
#include "libisofs.h"
#include <stdlib.h>
#include <string.h>
/**
* Increments the reference counting of the given node.
*/
void iso_node_ref(IsoNode *node)
{
++node->refcount;
}
/**
* Decrements the reference couting of the given node.
* If it reach 0, the node is free, and, if the node is a directory,
* its children will be unref() too.
*/
void iso_node_unref(IsoNode *node)
{
if (--node->refcount == 0) {
/* TODO #00002 handle deletion of each kind of node */
free(node->name);
free(node);
}
}
/**
* Set the name of a node.
*
* @param name The name in UTF-8 encoding
*/
void iso_node_set_name(IsoNode *node, const char *name)
{
free(node->name);
node->name = strdup(name);
}
/**
* Get the name of a node (in UTF-8).
* The returned string belongs to the node and should not be modified nor
* freed. Use strdup if you really need your own copy.
*/
const char *iso_node_get_name(IsoNode *node)
{
return node->name;
}