mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-22 23:30:54 +00:00
d4a7107bde
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@404 aa027e90-d47c-11dd-86d7-074df07e0730
64 lines
1.2 KiB
C++
64 lines
1.2 KiB
C++
#include "DirectoryEntry.h"
|
|
|
|
#include <cstring>
|
|
|
|
using namespace NuFX;
|
|
|
|
EntryPointer DirectoryEntry::lookup(const std::string& name) const
|
|
{
|
|
EntryIterator iter;
|
|
|
|
for (iter = _children.begin(); iter != _children.end(); ++iter)
|
|
{
|
|
|
|
EntryPointer e = *iter;
|
|
|
|
if (e->name() == name) return e;
|
|
}
|
|
|
|
return EntryPointer(); // empty.
|
|
}
|
|
|
|
DirectoryEntryPointer DirectoryEntry::dir_lookup(const std::string &name)
|
|
{
|
|
EntryIterator iter;
|
|
|
|
for (iter = _children.begin(); iter != _children.end(); ++iter)
|
|
{
|
|
|
|
EntryPointer e = *iter;
|
|
|
|
if (e->name() == name)
|
|
{
|
|
// dynamic cast, will return as empty pointer if
|
|
// not a directory.
|
|
|
|
return DYNAMIC_POINTER_CAST(DirectoryEntryPointer, e);
|
|
}
|
|
}
|
|
|
|
// not found, insert it..
|
|
|
|
DirectoryEntryPointer e(new DirectoryEntryPointer(name));
|
|
VolumeEntryPointer v = volume().lock();
|
|
|
|
_children.add(e);
|
|
|
|
if (v)
|
|
{
|
|
v->addEntry(e);
|
|
}
|
|
|
|
return e;
|
|
}
|
|
|
|
#pragma mark -
|
|
#pragma mark fuse-support
|
|
|
|
EntryPointer DirectoryEntry::childAtIndex(unsigned index) const
|
|
{
|
|
if (index >= _children.size()) return EntryPointer();
|
|
|
|
return _children[index];
|
|
}
|