#include "VNode.h"
\class VNode
\brief Represents a vnode, i.e. an object in a file system.
This class bundles all information relevant to a vnode, i.e. its ID,
the ID of its parent node and its stat data (for fast and convenient
access). VNode knows how to convert between the VFS ino_t
and the object+dir ID representation in ReiserFS.
*/
VNode::VNode()
: fParentID(0),
fDirID(0),
fObjectID(0),
fStatData()
{
}
VNode::VNode(const VNode &node)
: fParentID(0),
fDirID(0),
fObjectID(0),
fStatData()
{
*this = node;
}
VNode::VNode(ino_t id)
: fParentID(0),
fDirID(GetDirIDFor(id)),
fObjectID(GetObjectIDFor(id)),
fStatData()
{
}
VNode::VNode(uint32 dirID, uint32 objectID)
: fParentID(0),
fDirID(dirID),
fObjectID(objectID),
fStatData()
{
}
VNode::~VNode()
{
}
status_t
VNode::SetTo(ino_t id)
{
return SetTo(GetDirIDFor(id), GetObjectIDFor(id));
}
status_t
VNode::SetTo(uint32 dirID, uint32 objectID)
{
fParentID = 0;
fDirID = dirID;
fObjectID = objectID;
fStatData.Unset();
return B_OK;
}
ino_t
VNode::GetID() const
{
return GetIDFor(fDirID, fObjectID);
}
void
VNode::SetParentID(uint32 dirID, uint32 objectID)
{
SetParentID(GetIDFor(dirID, objectID));
}
VNode &
VNode::operator=(const VNode &node)
{
if (&node != this) {
fParentID = node.fParentID;
fDirID = node.fDirID;
fObjectID = node.fObjectID;
fStatData = node.fStatData;
}
return *this;
}