IDirectoryIterator

Iterates over the contents of a file system directory.

IDirectoryIterator is used to iterate over the contents of a directory. It can be used to iterate a single directory or to recursively iterate a directory and all of its subdirectories.

This class is designed to mimic a C++ pointer, similar to the iterator classes in the ANSI/ISO C++ draft standard. When the C++ Standard Library is available, IDirectoryIterator will inherit from input_iterator.

Typical usage is as follows: IDirectory myDirectory = ....;

for (IDirectoryIterator anEntity(myDirectory); anEntity; anEntity++) { DoSomething( *anEntity ); }


IDirectoryIterator - Member Functions and Data by Group

Constructors & Destructor

Use these to construct, copy, and assign directory iterators.


[view class]
~IDirectoryIterator
public:
virtual ~IDirectoryIterator()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IDirectoryIterator
Constructs an invalid, past-the-end iterator that you can use for Constructs an iterator over the contents of a given directory. Copy constructor

Copying a directory iterator does not do what you might expect. It creates another iterator object which refers to the same iteration. If you increment the new iterator, the original iterator is also incremented, because both objects actually refer to the same iteration.


Overload 1
public:
IDirectoryIterator()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
Copy constructor
public:
IDirectoryIterator(const IDirectoryIterator& copy)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 3
Constructs an iterator over the contents of a given directory.
public:
IDirectoryIterator( const IDirectory&, bool recursive = false )

directory
the directory over which to iterate
recursive
if true, also iterates over the contents of subdirectories. The default is false, to iterate over a single directory.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator =
Assignment operator
public:
IDirectoryIterator& operator =( const IDirectoryIterator& copy )

Assigning a directory iterator does not do what you might expect. It creates another iterator object which refers to the same iteration. If you increment the new iterator, the original iterator is also incremented, because both objects actually refer to the same iteration.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Accessors

Use these to access data members.


[view class]
recursive
public:
bool recursive() const
Returns true if this iteration is recursive.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Comparison and validation operators

User these operators to compare iterators and to confirm the validity of iterators.


[view class]
operator !=
public:
bool operator !=(const IDirectoryIterator& other) const
Inequality operator

Two directory iterators compare as equal if they are both past the end of their iteration, or if one was copy-constructed from the other.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator ==
public:
bool operator ==(const IDirectoryIterator& other) const
Equality operator

Two directory iterators compare as equal if they are both past the end of their iteration, or if one was copy-constructed from the other.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator bool
public:
operator bool() const
Validity test

This member function is often used in the termination condition of a for or while loop. When operator bool returns false, there are no more entities over which to iterate.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Standard iteration functions

Use these iteration operators to iterate through the directories.


[view class]
operator *
public:
IFileSystemEntity operator *() const
Returns the current entity in the iteration. This member function allows the iterator to be used as if it were a normal C++ pointer, in expressions like FunctionCall( *anIterator )

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator ++

Proceeds to the next entity in the iteration.


Overload 1
Pre-increment operator used for expressions like ++iterator.
public:
IDirectoryIterator& operator ++()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
IDirectoryIterator operator ++(int)

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator ->
Returns a pointer to the current entity in the iteration.
public:
IFileSystemEntity* operator ->()
This member function allows the iterator to be used as if it were a normal C++ pointer, in expressions like: anIterator->deleteSelf()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Miscellaneous Members


[view class]
end
public:
static const IDirectoryIterator& end()
Returns an iterator which represents the end of iteration.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IDirectoryIterator - Inherited Member Functions and Data

Inherited Public Functions

Inherited Public Data

Inherited Protected Functions

Inherited Protected Data