Deepsolver
|
The iterator over the files and subdirectories. More...
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. |
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.
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.
[in] | path | The name of directory used in file names construction |
[in] | dir | The valid handle to the directory to read data from |
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.
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.
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.