Thrill
0.1
|
Implementation of the SimpleGlob class.
Definition at line 550 of file simple_glob.hpp.
#include <simple_glob.hpp>
Public Member Functions | |
CSimpleGlobTempl (unsigned int a_uiFlags=0, int a_nReservedSlots=0) | |
Initialize the class. More... | |
~CSimpleGlobTempl () | |
Deallocate all memory buffers. More... | |
int | Add (const SOCHAR *a_pszFileSpec) |
Add a new filespec to the glob. More... | |
int | Add (int a_nCount, const SOCHAR *const *a_rgpszFileSpec) |
Add an array of filespec to the glob. More... | |
SOCHAR * | File (int n) |
Return the a single file. More... | |
int | FileCount () const |
Return the number of files in the argv array. More... | |
SOCHAR ** | Files () |
Return the full argv array. More... | |
int | Init (unsigned int a_uiFlags=0, int a_nReservedSlots=0) |
Initialize (or re-initialize) the class in preparation for adding new filespecs. More... | |
Private Types | |
enum | ARG_ARRAY_TYPE { OFFSETS, POINTERS } |
The argv array has it's members stored as either an offset into the string buffer, or as pointers to their string in the buffer. More... | |
Private Member Functions | |
CSimpleGlobTempl (const CSimpleGlobTempl &) | |
int | AppendName (const SOCHAR *a_pszFileName, bool a_bIsDir) |
Add a filename to the array if it passes all requirements. More... | |
bool | GrowArgvArray (int a_nNewLen) |
Grow the argv array to the required size. More... | |
bool | GrowStringBuffer (size_t a_uiMinSize) |
Grow the string buffer to the required size. More... | |
CSimpleGlobTempl & | operator= (const CSimpleGlobTempl &) |
void | SetArgvArrayType (ARG_ARRAY_TYPE a_nNewType) |
Change the type of data stored in the argv array. More... | |
Private Member Functions inherited from SimpleGlobBase< SOCHAR > | |
SimpleGlobBase () | |
~SimpleGlobBase () | |
void | FilePrep () |
void | FindDone () |
int | FindFirstFileS (const char *a_pszFileSpec, unsigned int a_uiFlags) |
bool | FindNextFileS (char) |
const char * | GetFileNameS (char) const |
SG_FileType | GetFileTypeS (const char *a_pszPath) const |
bool | IsDirS (char) const |
Static Private Member Functions | |
static int | fileSortCompare (const void *a1, const void *a2) |
Compare two (possible nullptr) strings. More... | |
Private Attributes | |
ARG_ARRAY_TYPE | m_nArgArrayType |
argv is indexes or pointers More... | |
int | m_nArgsLen |
used length More... | |
int | m_nArgsSize |
allocated size of array More... | |
int | m_nReservedSlots |
client slots in argv arrayMore... | |
SOCHAR * | m_pBuffer |
argv string buffer More... | |
SOCHAR ** | m_rgpArgs |
argv More... | |
SOCHAR | m_szPathPrefix [PATH_MAX] |
wildcard path prefix More... | |
size_t | m_uiBufferLen |
used length of buffer More... | |
size_t | m_uiBufferSize |
allocated size of buffer More... | |
unsigned int | m_uiFlags |
|
private |
The argv array has it's members stored as either an offset into the string buffer, or as pointers to their string in the buffer.
The offsets are used because if the string buffer is dynamically resized, all pointers into that buffer would become invalid.
Enumerator | |
---|---|
OFFSETS | |
POINTERS |
Definition at line 636 of file simple_glob.hpp.
|
explicit |
Initialize the class.
a_uiFlags | Combination of SG_GLOB flags. |
a_nReservedSlots | Number of slots in the argv array that should be reserved. In the returned array these slots argv[0] ... argv[a_nReservedSlots-1] will be left empty for the caller to fill in. |
Definition at line 671 of file simple_glob.hpp.
~CSimpleGlobTempl | ( | ) |
|
private |
int Add | ( | const SOCHAR * | a_pszFileSpec | ) |
Add a new filespec to the glob.
The filesystem will be immediately scanned for all matching files and directories and they will be added to the glob.
a_pszFileSpec | Filespec to add to the glob. |
Definition at line 715 of file simple_glob.hpp.
References SimpleGlobBase< SOCHAR >::FindDone(), MAX_PATH, thrill::vfs::glob_local::SG_ERR_NOMATCH, thrill::vfs::glob_local::SG_FILETYPE_DIR, thrill::vfs::glob_local::SG_FILETYPE_INVALID, thrill::vfs::glob_local::SG_GLOB_FULLSORT, thrill::vfs::glob_local::SG_GLOB_NOCHECK, thrill::vfs::glob_local::SG_GLOB_NOSORT, SG_PATH_CHAR, thrill::vfs::glob_local::SG_SUCCESS, SimpleGlobUtil::strchr(), SimpleGlobUtil::strcpy_s(), and SimpleGlobUtil::strrchr().
int Add | ( | int | a_nCount, |
const SOCHAR *const * | a_rgpszFileSpec | ||
) |
Add an array of filespec to the glob.
The filesystem will be immediately scanned for all matching files and directories in each filespec and they will be added to the glob.
a_nCount | Number of filespec in the array. |
a_rgpszFileSpec | Array of filespec to add to the glob. |
Definition at line 796 of file simple_glob.hpp.
References thrill::vfs::glob_local::SG_SUCCESS.
|
private |
Add a filename to the array if it passes all requirements.
Definition at line 812 of file simple_glob.hpp.
References thrill::vfs::glob_local::SG_ERR_MEMORY, thrill::vfs::glob_local::SG_GLOB_MARK, thrill::vfs::glob_local::SG_GLOB_NODOT, thrill::vfs::glob_local::SG_GLOB_ONLYDIR, thrill::vfs::glob_local::SG_GLOB_ONLYFILE, SG_PATH_CHAR, thrill::vfs::glob_local::SG_SUCCESS, SimpleGlobUtil::strcpy_s(), and SimpleGlobUtil::strlen().
|
inline |
|
inline |
Return the number of files in the argv array.
Definition at line 613 of file simple_glob.hpp.
|
inline |
Return the full argv array.
Definition at line 616 of file simple_glob.hpp.
|
staticprivate |
Compare two (possible nullptr) strings.
Definition at line 937 of file simple_glob.hpp.
References SimpleGlobUtil::strcasecmp().
|
private |
Grow the argv array to the required size.
Definition at line 897 of file simple_glob.hpp.
References realloc().
|
private |
Grow the string buffer to the required size.
Definition at line 917 of file simple_glob.hpp.
References realloc().
int Init | ( | unsigned int | a_uiFlags = 0 , |
int | a_nReservedSlots = 0 |
||
) |
Initialize (or re-initialize) the class in preparation for adding new filespecs.
All existing files are cleared. Note that allocated memory is only deallocated at object destruction.
a_uiFlags | Combination of SG_GLOB flags. |
a_nReservedSlots | Number of slots in the argv array that should be reserved. In the returned array these slots argv[0] ... argv[a_nReservedSlots-1] will be left empty for the caller to fill in. |
Definition at line 691 of file simple_glob.hpp.
References thrill::vfs::glob_local::SG_ERR_MEMORY, and thrill::vfs::glob_local::SG_SUCCESS.
|
private |
|
private |
Change the type of data stored in the argv array.
Definition at line 872 of file simple_glob.hpp.
References SG_ASSERT.
|
private |
argv is indexes or pointers
Definition at line 655 of file simple_glob.hpp.
|
private |
used length
Definition at line 659 of file simple_glob.hpp.
|
private |
allocated size of array
Definition at line 658 of file simple_glob.hpp.
|
private |
Definition at line 657 of file simple_glob.hpp.
|
private |
argv string buffer
Definition at line 660 of file simple_glob.hpp.
|
private |
argv
Definition at line 656 of file simple_glob.hpp.
|
private |
wildcard path prefix
Definition at line 663 of file simple_glob.hpp.
|
private |
used length of buffer
Definition at line 662 of file simple_glob.hpp.
|
private |
allocated size of buffer
Definition at line 661 of file simple_glob.hpp.
|
private |
Definition at line 654 of file simple_glob.hpp.