Plasma Engine  2.0
Loading...
Searching...
No Matches
plFileSystemIterator Class Reference

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

#include <OSFile.h>

Public Member Functions

void StartSearch (plStringView sSearchTerm, plBitflags< plFileSystemIteratorFlags > flags=plFileSystemIteratorFlags::Default)
 Starts a search at the given folder. Use * and ? as wildcards.
 
void StartMultiFolderSearch (plArrayPtr< plString > startFolders, plStringView sSearchTerm, plBitflags< plFileSystemIteratorFlags > flags=plFileSystemIteratorFlags::Default)
 The same as StartSearch() but executes the same search on multiple folders.
 
const plStringView GetCurrentSearchTerm () const
 Returns the search string with which StartSearch() was called.
 
const plStringBuilderGetCurrentPath () const
 Returns the current path in which files are searched. Changes when 'Next' moves in or out of a sub-folder.
 
const plFileStatsGetStats () 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.
 

Detailed Description

An plFileSystemIterator 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

◆ GetCurrentPath()

const plStringBuilder & plFileSystemIterator::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'

◆ GetCurrentSearchTerm()

const plStringView plFileSystemIterator::GetCurrentSearchTerm ( ) const
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.

◆ StartMultiFolderSearch()

void plFileSystemIterator::StartMultiFolderSearch ( plArrayPtr< plString > startFolders,
plStringView sSearchTerm,
plBitflags< plFileSystemIteratorFlags > flags = plFileSystemIteratorFlags::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.

◆ StartSearch()

void plFileSystemIterator::StartSearch ( plStringView sSearchTerm,
plBitflags< plFileSystemIteratorFlags > flags = plFileSystemIteratorFlags::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 PL_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), PL_FAILURE is returned.


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