Directory iterators.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
24ec5f4377
commit
42ba13e82b
50
src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp
Normal file
50
src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp
Normal 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;
|
||||
}
|
||||
|
||||
|
49
src/add-ons/kernel/file_systems/udf/DirectoryIterator.h
Normal file
49
src/add-ons/kernel/file_systems/udf/DirectoryIterator.h
Normal 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
|
Loading…
Reference in New Issue
Block a user