Deepsolver
Public Member Functions
Directory::Iterator Class Reference

The iterator over the files and subdirectories. More...

List of all members.

Public Member Functions

std::string fullPath () const
 Returns the name of directory item this iterator is pointing to with parent directory.
 Iterator (const std::string &path, DIR *dir)
 The constructor.
bool moveNext ()
 Moves the iterator to next item.
std::string name () const
 Returns the name of directory item this iterator is pointing to.
virtual ~Iterator ()
 The destructor.

Detailed Description

This class returns all items in some directory. Each item can be examined both as just the name of a file and as the name with parent directories.

The iterator is created pointed before the first item. So the user have to call moveNext() method at least once to be able use methods to get name of files.


Constructor & Destructor Documentation

Directory::Iterator::Iterator ( const std::string &  path,
DIR *  dir 
) [inline]

This is the main constructor. It takes the name of directory it enumerates and the opened handle to directory. It is strongly recommended to use enumerate() method of Directory class, however the user can create this iterator explicitly.

Parameters:
[in]pathThe name of directory used in file names construction
[in]dirThe valid handle to the directory to read data from

Member Function Documentation

std::string Directory::Iterator::fullPath ( ) const

This method returns the name of a file or directory the iterator is pointing to with path of the parent directory. If method is called before the first invocation of moveNext() or after it has already returned zero this method behaviour is undefined.

Returns:
The name of item the iterator is pointing to with parent directory
bool Directory::Iterator::moveNext ( )

This method moves the iterator to the first item on its first invocation or to the next on each consequent. The method returns zero if next item does not exist. If method returns zero on first call it means the directory is empty.

Returns:
Non-zero if next item exists or zero if there is no next item or directory is empty
std::string Directory::Iterator::name ( ) const

This method returns the name of a file or directory the iterator is pointing to without path of the parent directory. If method is called before the first invocation of moveNext() or after it has already returned zero this method behaviour is undefined.

Returns:
The name of item the iterator is pointing to without parent directory