diff --git a/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp new file mode 100644 index 0000000000..44ac419539 --- /dev/null +++ b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp @@ -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; +} + + diff --git a/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h new file mode 100644 index 0000000000..223e49ef15 --- /dev/null +++ b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h @@ -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 +} + +#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