Searches through a the files in a directory, returning each file that is found. More...
Classes | |
| class | NativeIterator |
Public Member Functions | |
| DirectoryIterator (const File &directory, bool isRecursive, const String &wildCard="*", int whatToLookFor=File::findFiles) | |
| Creates a DirectoryIterator for a given directory. | |
| ~DirectoryIterator () | |
| Destructor. | |
| bool | next () |
| Moves the iterator along to the next file. | |
| bool | next (bool *isDirectory, bool *isHidden, int64 *fileSize, Time *modTime, Time *creationTime, bool *isReadOnly) |
| Moves the iterator along to the next file, and returns various properties of that file. | |
| const File | getFile () const |
| Returns the file that the iterator is currently pointing at. | |
| float | getEstimatedProgress () const |
| Returns a guess of how far through the search the iterator has got. | |
Searches through a the files in a directory, returning each file that is found.
A DirectoryIterator will search through a directory and its subdirectories using a wildcard filepattern match.
If you may be finding a large number of files, this is better than using File::findChildFiles() because it doesn't block while it finds them all, and this is more memory-efficient.
It can also guess how far it's got using a wildly inaccurate algorithm.
| DirectoryIterator::DirectoryIterator | ( | const File & | directory, | |
| bool | isRecursive, | |||
| const String & | wildCard = "*", |
|||
| int | whatToLookFor = File::findFiles | |||
| ) |
Creates a DirectoryIterator for a given directory.
After creating one of these, call its next() method to get the first file - e.g.
DirectoryIterator iter (File ("/animals/mooses"), true, "*.moose"); while (iter.next()) { File theFileItFound (iter.getFile()); ... etc }
| directory | the directory to search in | |
| isRecursive | whether all the subdirectories should also be searched | |
| wildCard | the file pattern to match | |
| whatToLookFor | a value from the File::TypesOfFileToFind enum, specifying whether to look for files, directories, or both. |
| DirectoryIterator::~DirectoryIterator | ( | ) |
Destructor.
| bool DirectoryIterator::next | ( | ) |
Moves the iterator along to the next file.
| bool DirectoryIterator::next | ( | bool * | isDirectory, | |
| bool * | isHidden, | |||
| int64 * | fileSize, | |||
| Time * | modTime, | |||
| Time * | creationTime, | |||
| bool * | isReadOnly | |||
| ) |
Moves the iterator along to the next file, and returns various properties of that file.
If you need to find out details about the file, it's more efficient to call this method than to call the normal next() method and then find out the details afterwards.
All the parameters are optional, so pass null pointers for any items that you're not interested in.
| const File DirectoryIterator::getFile | ( | ) | const |
Returns the file that the iterator is currently pointing at.
The result of this call is only valid after a call to next() has returned true.
| float DirectoryIterator::getEstimatedProgress | ( | ) | const |
Returns a guess of how far through the search the iterator has got.
1.6.3