#include "Entry.h"
#include "Directory.h"
#include "FDManager.h"
#include "Path.h"
#include "Volume.h"
#include "VolumeManager.h"
Entry::Entry(Volume* volume, Directory* directory, const char* name, Node* node)
: fVolume(volume),
fDirectory(directory),
fName(name),
fNode(node),
fDirEntryLink()
{
}
Entry::~Entry()
{
}
status_t
Entry::InitCheck() const
{
return (fName.GetLength() > 0 ? B_OK : B_NO_MEMORY);
}
Volume*
Entry::GetVolume() const
{
return fVolume;
}
Directory*
Entry::GetDirectory() const
{
return fDirectory;
}
NoAllocEntryRef
Entry::GetEntryRef() const
{
return NoAllocEntryRef(fVolume->GetID(), fDirectory->GetID(),
fName.GetString());
}
dev_t
Entry::GetVolumeID() const
{
return fVolume->GetID();
}
ino_t
Entry::GetDirectoryID() const
{
return fDirectory->GetID();
}
const char*
Entry::GetName() const
{
return fName.GetString();
}
Node*
Entry::GetNode() const
{
return fNode;
}
status_t
Entry::GetPath(Path* path)
{
return VolumeManager::GetDefault()->GetPath(this, path);
}
bool
Entry::Exists() const
{
NoAllocEntryRef entryRef(GetEntryRef());
BEntry bEntry;
return (FDManager::SetEntry(&bEntry, &entryRef) == B_OK && bEntry.Exists());
}
bool
Entry::IsActualEntry() const
{
return (fName.GetLength() > 0 && fName != "." && fName != "..");
}