Class Poco::DirectoryIterator
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco

# class DirectoryIterator

Library: Foundation
Package: Filesystem
Header: Poco/DirectoryIterator.h

## Description

The DirectoryIterator class is used to enumerate all files in a directory.

DirectoryIterator has some limitations:

- only forward iteration (++) is supported
- an iterator copied from another one will always point to the same file as the original iterator, even is the original iterator has been advanced (all copies of an iterator share their state with the original iterator)
- because of this you should only use the prefix increment operator

## Inheritance

Known Derived Classes: SortedDirectoryIterator

## Member Summary

Member Functions: name, operator !=, operator *, operator ++, operator =, operator ==, operator->, path

## Constructors

### DirectoryIterator

DirectoryIterator();

Creates the end iterator.

### DirectoryIterator

DirectoryIterator(
const std::string & path
);

Creates a directory iterator for the given path.

### DirectoryIterator

DirectoryIterator(
const DirectoryIterator & iterator
);

Creates a directory iterator for the given path.

### DirectoryIterator

DirectoryIterator(
const File & file
);

Creates a directory iterator for the given file.

### DirectoryIterator

DirectoryIterator(
const Path & path
);

Creates a directory iterator for the given path.

## Destructor

### ~DirectoryIterator

virtual ~DirectoryIterator();

Destroys the DirectoryIterator.

## Member Functions

### name

const std::string & name() const;

Returns the current filename.

### operator !=

bool operator != (
const DirectoryIterator & iterator
) const;

### operator *

const File & operator * () const;

### operator *

File & operator * ();

### operator ++

virtual DirectoryIterator & operator ++ ();

### operator ++

DirectoryIterator operator ++ (
int
);

Deprecated. This function is deprecated and should no longer be used.

Please use the prefix increment operator instead.

### operator =

DirectoryIterator & operator = (
const DirectoryIterator & it
);

### operator =

DirectoryIterator & operator = (
const File & file
);

### operator =

DirectoryIterator & operator = (
const Path & path
);

### operator =

DirectoryIterator & operator = (
const std::string & path
);

### operator ==

bool operator == (
const DirectoryIterator & iterator
) const;

### operator->

const File * operator-> () const;

### operator->

File * operator-> ();

### path

const Path & path() const;

Returns the current path.

## Variables

### _file

File _file;

### _path

Path _path;