Directory iterators.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder 2003-07-10 19:41:45 +00:00
parent 24ec5f4377
commit 42ba13e82b
2 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,50 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
//---------------------------------------------------------------------
/*! \file DirectoryIterator.cpp
*/
#include "DirectoryIterator.h"
using namespace Udf;
status_t
DirectoryIterator::GetNextEntry(vnode_id *id, char *name, uint32 *length)
{
if (!id || !name || !length)
return B_BAD_VALUE;
if (fCount < 5)
sprintf(name, "entry #%d", fCount++);
else
return B_ENTRY_NOT_FOUND;
return B_OK;
}
/* \brief Rewinds the iterator to point to the first
entry in the directory.
*/
void
DirectoryIterator::Rewind()
{
fCount = 0;
}
DirectoryIterator::DirectoryIterator(Icb *parent)
: fParent(parent)
, fCount(0)
{
}
void
DirectoryIterator::Invalidate()
{
fParent = NULL;
}

View File

@ -0,0 +1,49 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
//---------------------------------------------------------------------
#ifndef _UDF_DIRECTORY_ITERATOR_H
#define _UDF_DIRECTORY_ITERATOR_H
/*! \file DirectoryIterator.h
*/
extern "C" {
#ifndef _IMPEXP_KERNEL
# define _IMPEXP_KERNEL
#endif
#include <fsproto.h>
}
#include "cpp.h"
#include "UdfDebug.h"
namespace Udf {
class Icb;
class DirectoryIterator {
public:
status_t GetNextEntry(vnode_id *id, char *name, uint32 *length);
void Rewind();
Icb* Parent() const { return fParent; }
private:
friend class Icb;
DirectoryIterator(); // unimplemented
DirectoryIterator(Icb *parent); // called by Icb::GetDirectoryIterator()
void Invalidate(); // called by Icb::~Icb()
Icb *fParent;
uint32 fCount; // Used to implement fake iteration until file reading is implemented
};
}; // namespace Udf
#endif // _UDF_DIRECTORY_ITERATOR_H