FreeSWITCH API Documentation
1.7.0
|
Implementation of the SimpleGlob class. More...
#include <SimpleGlob.h>
Public Member Functions | |
CSimpleGlobTempl (unsigned int a_uiFlags=0, int a_nReservedSlots=0) | |
Initialize the class. More... | |
~CSimpleGlobTempl () | |
Deallocate all memory buffers. 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... | |
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... | |
int | FileCount () const |
Return the number of files in the argv array. More... | |
SOCHAR ** | Files () |
Return the full argv array. More... | |
SOCHAR * | File (int n) |
Return the a single file. 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. The offsets are used because if the string buffer is dynamically resized, all pointers into that buffer would become invalid. More... | |
Private Member Functions | |
void | SetArgvArrayType (ARG_ARRAY_TYPE a_nNewType) |
Change the type of data stored in the argv array. More... | |
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... | |
Private Member Functions inherited from SimpleGlobBase< SOCHAR > | |
SimpleGlobBase () | |
~SimpleGlobBase () | |
void | FilePrep () |
int | FindFirstFileS (const char *a_pszFileSpec, unsigned int a_uiFlags) |
bool | FindNextFileS (char) |
void | FindDone () |
const char * | GetFileNameS (char) const |
bool | IsDirS (char) const |
SG_FileType | GetFileTypeS (const char *a_pszPath) const |
Static Private Member Functions | |
static int | fileSortCompare (const void *a1, const void *a2) |
Compare two (possible NULL) strings. More... | |
Private Attributes | |
unsigned int | m_uiFlags |
ARG_ARRAY_TYPE | m_nArgArrayType |
is the argv array storing indexes or pointers More... | |
SOCHAR ** | m_rgpArgs |
argv array More... | |
int | m_nReservedSlots |
number of client reserved slots in the argv array More... | |
int | m_nArgsSize |
allocated size of array More... | |
int | m_nArgsLen |
used length More... | |
SOCHAR * | m_pBuffer |
argv string buffer More... | |
size_t | m_uiBufferSize |
allocated size of buffer More... | |
size_t | m_uiBufferLen |
used length of buffer More... | |
SOCHAR | m_szPathPrefix [MAX_PATH] |
path prefix of any wildcard filenames More... | |
Implementation of the SimpleGlob class.
Definition at line 431 of file SimpleGlob.h.
|
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 513 of file SimpleGlob.h.
CSimpleGlobTempl< SOCHAR >::CSimpleGlobTempl | ( | unsigned int | a_uiFlags = 0 , |
int | a_nReservedSlots = 0 |
||
) |
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 547 of file SimpleGlob.h.
CSimpleGlobTempl< SOCHAR >::~CSimpleGlobTempl | ( | ) |
int CSimpleGlobTempl< SOCHAR >::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 585 of file SimpleGlob.h.
References MAX_PATH, SG_ERR_NOMATCH, SG_FILETYPE_DIR, SG_FILETYPE_INVALID, SG_GLOB_FULLSORT, SG_GLOB_NOCHECK, SG_GLOB_NOSORT, SG_PATH_CHAR, SG_SUCCESS, SimpleGlobUtil::strchr(), SimpleGlobUtil::strcpy_s(), and SimpleGlobUtil::strrchr().
int CSimpleGlobTempl< SOCHAR >::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 655 of file SimpleGlob.h.
References SG_SUCCESS.
|
private |
Add a filename to the array if it passes all requirements.
Definition at line 667 of file SimpleGlob.h.
References SG_ERR_MEMORY, SG_GLOB_MARK, SG_GLOB_NODOT, SG_GLOB_ONLYDIR, SG_GLOB_ONLYFILE, SG_PATH_CHAR, SG_SUCCESS, SimpleGlobUtil::strcpy_s(), and SimpleGlobUtil::strlen().
|
inline |
Return the a single file.
Definition at line 502 of file SimpleGlob.h.
References CSimpleGlobTempl< SOCHAR >::Files(), CSimpleGlobTempl< SOCHAR >::m_nArgsLen, and SG_ASSERT.
|
inline |
Return the number of files in the argv array.
Definition at line 493 of file SimpleGlob.h.
References CSimpleGlobTempl< SOCHAR >::m_nArgsLen.
|
inline |
Return the full argv array.
Definition at line 496 of file SimpleGlob.h.
References CSimpleGlobTempl< SOCHAR >::m_rgpArgs, CSimpleGlobTempl< SOCHAR >::POINTERS, and CSimpleGlobTempl< SOCHAR >::SetArgvArrayType().
Referenced by CSimpleGlobTempl< SOCHAR >::File().
|
staticprivate |
Compare two (possible NULL) strings.
Definition at line 770 of file SimpleGlob.h.
References SimpleGlobUtil::strcasecmp().
|
private |
|
private |
Grow the string buffer to the required size.
Definition at line 753 of file SimpleGlob.h.
int CSimpleGlobTempl< SOCHAR >::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 565 of file SimpleGlob.h.
References SG_ERR_MEMORY, and SG_SUCCESS.
|
private |
Change the type of data stored in the argv array.
Definition at line 717 of file SimpleGlob.h.
References SG_ASSERT.
Referenced by CSimpleGlobTempl< SOCHAR >::Files().
|
private |
is the argv array storing indexes or pointers
Definition at line 532 of file SimpleGlob.h.
|
private |
used length
Definition at line 536 of file SimpleGlob.h.
Referenced by CSimpleGlobTempl< SOCHAR >::File(), and CSimpleGlobTempl< SOCHAR >::FileCount().
|
private |
allocated size of array
Definition at line 535 of file SimpleGlob.h.
|
private |
number of client reserved slots in the argv array
Definition at line 534 of file SimpleGlob.h.
|
private |
argv string buffer
Definition at line 537 of file SimpleGlob.h.
|
private |
argv array
Definition at line 533 of file SimpleGlob.h.
Referenced by CSimpleGlobTempl< SOCHAR >::Files().
|
private |
path prefix of any wildcard filenames
Definition at line 540 of file SimpleGlob.h.
|
private |
used length of buffer
Definition at line 539 of file SimpleGlob.h.
|
private |
allocated size of buffer
Definition at line 538 of file SimpleGlob.h.
|
private |
Definition at line 531 of file SimpleGlob.h.