DirectoryTokenizer

The DirectoryTokenizer is a class that can be used to recursively scan directories in a file-by-file manner rather than parsing the entire tree at once.

Interface

DirectoryTokenizer(std::string rootDirectory,
		   unsigned maxDepth = 255u)
Creates a DirectoryTokenizer object set to scan the specified rootDirectory, going at most maxDepth deep into the tree.
bool next(std::string &fileName)
Stores the name of the next file in fileName if there is one available. Return true if a file was found and fileName is updated; returns false if no next file is available. Once a false is returned, there are no files left in the directory tree and the scan is complete.
bool ok() const
Returns true if the object is in good state. Returns false if, for example, the rootDirectory could not be opened.
bool complete() const
Returns true if the scan has completed.

Example

Printing all files in the directory tree under the current directory:
	cvmlcpp::DirectoryTokenizer dt(".");
	std::string fileName;

	if (dt.ok())
	{
		while(dt.next(fileName))
			std::cout << fileName << std::endl;
	}
	else
		std::cout << "ERROR!" << std::endl;