C12Adapter Opensource C++ Interface
|
Operating system and compiler independent way to search for file or directory. More...
Public Member Functions | |
MFindFile () | |
Default constructor, no search is initialized. | |
MFindFile (MConstChars directory, MConstChars fileMask, bool searchForDirectories=false, bool reserved=false, bool excludeDotFiles=false) | |
Constructor, which initializes the search. More... | |
~MFindFile () | |
Object destructor. | |
void | Close () |
Close the result of the previous search. More... | |
void | Init (MConstChars directory, MConstChars fileMask, bool searchForDirectories=false, bool reserved=false, bool excludeDotFiles=false) |
Initialize the search. More... | |
MConstChars | FindNext (bool returnFullPath=true) |
Find the next file that corresponds to the initialization parameters of the object. More... | |
Static Public Member Functions | |
static void | Populate (MStdStringVector &result, const MStdString &directory, const MStdString &fileMask, bool searchForDirectories=false, bool reserved=false, bool excludeDotFiles=false) |
Populate the result vector with files from the given directory. More... | |
Operating system and compiler independent way to search for file or directory.
MFindFile::MFindFile | ( | MConstChars | directory, |
MConstChars | fileMask, | ||
bool | searchForDirectories = false , |
||
bool | reserved = false , |
||
bool | excludeDotFiles = false |
||
) |
Constructor, which initializes the search.
It is not an error if the directory does not exist. In this case, FindNext returns NULL.
directory | Path to a directory where to search for files or subdirectories. It can be full path or path relative to current directory. |
fileMask | The file mask cannot contain a subdirectory. Regular file mask syntax applies, * and ? can be used for a sequence of characters and for a single character. |
searchForDirectories | When true, the search is done for directories only. Otherwise, when false, the search is done only for ordinary files. |
reserved | Reserved parameter that has no effect. |
excludeDotFiles | Special directories '.' and '..' are never listed, but when this parameter is true, any file that starts with period, such as ".svn", will not appear in the result search. |
void MFindFile::Close | ( | ) |
Close the result of the previous search.
It is always safe to call Close, any number of times.
MConstChars MFindFile::FindNext | ( | bool | returnFullPath = true | ) |
Find the next file that corresponds to the initialization parameters of the object.
Note that the storage for the file name is allocated inside the class. It should not be attempted to be deleted.
If the search for directories was initiated, then the file returned is a directory name, otherwise this is non-directory name.
returnFullPath | If true, return the full path. Otherwise, return only file and extension. |
void MFindFile::Init | ( | MConstChars | directory, |
MConstChars | fileMask, | ||
bool | searchForDirectories = false , |
||
bool | reserved = false , |
||
bool | excludeDotFiles = false |
||
) |
Initialize the search.
It is not an error if the directory does not exist. In this case, FindNext returns NULL.
directory | Path to a directory where to search for files or subdirectories. It can be full path or path relative to current directory. |
fileMask | The file mask cannot contain a subdirectory. Regular file mask syntax applies, * and ? can be used for a sequence of characters and for a single character. |
searchForDirectories | When true, the search is done for directories only. Otherwise, when false, the search is done only for ordinary files. |
reserved | Reserved parameter that has no effect. |
excludeDotFiles | Special directories '.' and '..' are never listed, but when this parameter is true, any file that starts with period, such as ".svn", will not appear in the result search. |
|
inlinestatic |
Populate the result vector with files from the given directory.
This method combines the search initializer with FindNext.
result | String vector, shall be empty prior to this call, will be populated with file names. |
directory | Path to a directory where to search for files or subdirectories. It can be full path or path relative to current directory. |
fileMask | The file mask cannot contain a subdirectory. Regular file mask syntax applies, * and ? can be used for a sequence of characters and for a single character. |
searchForDirectories | When true, the search is done for directories only. Otherwise, when false, the search is done only for ordinary files. |
reserved | Reserved parameter that has no effect. |
excludeDotFiles | Special directories '.' and '..' are never listed, but when this parameter is true, any file that starts with period, such as ".svn", will not appear in the result search. |