![]() |
XII Release 0.1.0
|
A xiiFileSystemIterator allows to iterate over all files in a certain directory. More...
#include <OSFile.h>
Public Member Functions | |
void | StartSearch (xiiStringView sSearchTerm, xiiBitflags< xiiFileSystemIteratorFlags > flags=xiiFileSystemIteratorFlags::Default) |
Starts a search at the given folder. Use * and ? as wildcards. | |
void | StartMultiFolderSearch (xiiArrayPtr< xiiString > startFolders, xiiStringView sSearchTerm, xiiBitflags< xiiFileSystemIteratorFlags > flags=xiiFileSystemIteratorFlags::Default) |
The same as StartSearch() but executes the same search on multiple folders. | |
const xiiStringView | GetCurrentSearchTerm () const |
Returns the search string with which StartSearch() was called. | |
const xiiStringBuilder & | GetCurrentPath () const |
Returns the current path in which files are searched. Changes when 'Next' moves in or out of a sub-folder. | |
const xiiFileStats & | GetStats () const |
Returns the file stats of the current object that the iterator points to. | |
void | Next () |
Advances the iterator to the next file object. Might recurse into sub-folders. | |
void | SkipFolder () |
The same as 'Next' only that the current folder will not be recursed into. | |
bool | IsValid () const |
Returns true if the iterator currently points to a valid file entry. | |
A xiiFileSystemIterator allows to iterate over all files in a certain directory.
The search can be recursive, and it can contain wildcards (* and ?) to limit the search to specific file types.
|
inline |
Returns the current path in which files are searched. Changes when 'Next' moves in or out of a sub-folder.
You can use this to get the full path of the current file, by appending this value and the filename from 'GetStats'
|
inline |
Returns the search string with which StartSearch() was called.
If StartMultiFolderSearch() is used, every time a new top-level folder is entered, StartSearch() is executed. In this case GetCurrentSearchTerm() can be used to know in which top-level folder the search is currently running.
void xiiFileSystemIterator::StartMultiFolderSearch | ( | xiiArrayPtr< xiiString > | startFolders, |
xiiStringView | sSearchTerm, | ||
xiiBitflags< xiiFileSystemIteratorFlags > | flags = xiiFileSystemIteratorFlags::Default ) |
The same as StartSearch() but executes the same search on multiple folders.
The search term is appended to each start folder and they are searched one after the other.
void xiiFileSystemIterator::StartSearch | ( | xiiStringView | sSearchTerm, |
xiiBitflags< xiiFileSystemIteratorFlags > | flags = xiiFileSystemIteratorFlags::Default ) |
Starts a search at the given folder. Use * and ? as wildcards.
To iterate all files from one folder, use '/Some/Folder' To iterate over all files of a certain type (in one folder) use '/Some/Folder/*.ext' Only the final path segment can use placeholders, folders in between must be fully named. If bRecursive is false, the iterator will only iterate over the files in the start folder, and will not recurse into subdirectories. If bReportFolders is false, only files will be reported, folders will be skipped (though they will be recursed into, if bRecursive is true).
If XII_SUCCESS is returned, the iterator points to a valid file, and the functions GetCurrentPath() and GetStats() will return the information about that file. To advance to the next file, use Next() or SkipFolder(). When no iteration is possible (the directory does not exist or the wild-cards are used incorrectly), XII_FAILURE is returned.