ezEngine  Milestone 7
ezFileSystemIterator Class Reference

An ezFileSystemIterator allows to iterate over all files in a certain directory. More...

#include <OSFile.h>

Public Member Functions

ezResult StartSearch (const char *szSearchStart, bool bRecursive=true, bool bReportFolders=true)
 Starts a search at the given folder. Use * and ? as wildcards. More...
 
const ezStringBuilderGetCurrentPath () const
 Returns the current path in which files are searched. Changes when 'Next' moves in or out of a sub-folder. More...
 
const ezFileStatsGetStats () const
 Returns the file stats of the current object that the iterator points to.
 
ezResult Next ()
 Advances the iterator to the next file object. Might recurse into sub-folders. More...
 
ezResult SkipFolder ()
 The same as 'Next' only that the current folder will not be recursed into. More...
 

Private Member Functions

 EZ_DISALLOW_COPY_AND_ASSIGN (ezFileSystemIterator)
 

Private Attributes

ezStringBuilder m_sCurPath
 The current path of the folder, in which the iterator currently is.
 
bool m_bRecursive
 Whether to do a recursive file search.
 
bool m_bReportFolders
 Whether to report folders to the user, or to skip over them.
 
ezFileStats m_CurFile
 The stats about the file that the iterator currently points to.
 
ezFileIterationData m_Data
 Platform specific data, required by the implementation.
 

Detailed Description

An ezFileSystemIterator 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.

Member Function Documentation

const ezStringBuilder& ezFileSystemIterator::GetCurrentPath ( ) const
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'

ezResult ezFileSystemIterator::Next ( )

Advances the iterator to the next file object. Might recurse into sub-folders.

Returns false, if the search has reached its end.

ezResult ezFileSystemIterator::SkipFolder ( )

The same as 'Next' only that the current folder will not be recursed into.

Returns false, if the search has reached its end.

ezResult ezFileSystemIterator::StartSearch ( const char *  szSearchStart,
bool  bRecursive = true,
bool  bReportFolders = true 
)

Starts a search at the given folder. Use * and ? as wildcards.

To iterate all files from on 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 EZ_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 wildcards are used incorrectly), EZ_FAILURE is returned.


The documentation for this class was generated from the following files: