Poco

template < class TTravStr = ChildrenFirstTraverse >

class RecursiveDirectoryIterator

File Information

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

Description

The RecursiveDirectoryIterator class is used to enumerate all files in a directory and its subdirectories.

RecursiveDirectoryIterator 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)

The class can follow different traversal strategies:

  • depth-first strategy;
  • siblings-first strategy.

The strategies are set by template parameter. There are two corresponding typedefs:

The depth of traversal can be limited by constructor parameter maxDepth (which sets the infinite depth by default).

Member Summary

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

Types

MyType

typedef RecursiveDirectoryIterator < TTravStr > MyType;

Enumerations

Anonymous

D_INFINITE = 0

Constant for infinite traverse depth.

Constructors

RecursiveDirectoryIterator inline

RecursiveDirectoryIterator();

Creates the end iterator.

RecursiveDirectoryIterator inline

RecursiveDirectoryIterator(
    const MyType & iterator
);

Creates a copy of another recursive directory iterator.

RecursiveDirectoryIterator inline

RecursiveDirectoryIterator(
    const std::string & path,
    UInt16 maxDepth = D_INFINITE
);

Creates a recursive directory iterator for the given path.

RecursiveDirectoryIterator inline

RecursiveDirectoryIterator(
    const DirectoryIterator & iterator,
    UInt16 maxDepth = D_INFINITE
);

Creates a recursive directory iterator for the path of non-recursive directory iterator.

RecursiveDirectoryIterator inline

RecursiveDirectoryIterator(
    const File & file,
    UInt16 maxDepth = D_INFINITE
);

Creates a recursive directory iterator for the given path.

RecursiveDirectoryIterator inline

RecursiveDirectoryIterator(
    const Path & path,
    UInt16 maxDepth = D_INFINITE
);

Creates a recursive directory iterator for the given path.

Destructor

~RecursiveDirectoryIterator inline

~RecursiveDirectoryIterator();

Destroys the DirectoryIterator.

Member Functions

depth inline

UInt16 depth() const;

Depth of recursion (counting from 1).

maxDepth inline

UInt16 maxDepth() const;

Max depth of recursion (counting from 1).

name inline

const std::string & name() const;

Returns the current filename.

operator != inline

template < class T1, class T2 > friend inline bool operator != (
    const RecursiveDirectoryIterator < T1 > & a,
    const RecursiveDirectoryIterator < T2 > & b
);

operator * inline

const File & operator * () const;

operator * inline

File & operator * ();

operator ++ inline

MyType & operator ++ ();

operator = inline

MyType & operator = (
    const MyType & it
);

operator = inline

MyType & operator = (
    const File & file
);

operator = inline

MyType & operator = (
    const Path & path
);

operator = inline

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

operator == inline

template < class T1, class T2 > friend inline bool operator == (
    const RecursiveDirectoryIterator < T1 > & a,
    const RecursiveDirectoryIterator < T2 > & b
);

operator-> inline

const File * operator-> () const;

operator-> inline

File * operator-> ();

path inline

const Poco::Path & path() const;

Returns the current path.