RTS API Documentation  1.10.11
Public Member Functions | Private Attributes
SimpleGlobBase< SOCHAR > Struct Template Reference

Unix glob implementation. More...

#include <SimpleGlob.h>

+ Inheritance diagram for SimpleGlobBase< SOCHAR >:
+ Collaboration diagram for SimpleGlobBase< SOCHAR >:

Public Member Functions

 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
 

Private Attributes

glob_t m_glob
 
size_t m_uiCurr
 
bool m_bIsDir
 

Detailed Description

template<class SOCHAR>
struct SimpleGlobBase< SOCHAR >

Unix glob implementation.

Definition at line 342 of file SimpleGlob.h.

Constructor & Destructor Documentation

◆ SimpleGlobBase()

template<class SOCHAR >
SimpleGlobBase< SOCHAR >::SimpleGlobBase ( )
inline

Definition at line 343 of file SimpleGlob.h.

References memset().

343  {
344  memset(&m_glob, 0, sizeof(m_glob));
345  m_uiCurr = (size_t) -1;
346  } ~SimpleGlobBase() {
memset(buf, 0, buflen)
size_t m_uiCurr
Definition: SimpleGlob.h:418

◆ ~SimpleGlobBase()

template<class SOCHAR >
SimpleGlobBase< SOCHAR >::~SimpleGlobBase ( )
inline

Definition at line 346 of file SimpleGlob.h.

346  {
347  globfree(&m_glob);
348  }

Member Function Documentation

◆ FilePrep()

template<class SOCHAR >
void SimpleGlobBase< SOCHAR >::FilePrep ( )
inline

Definition at line 350 of file SimpleGlob.h.

References SimpleGlobUtil::strlen().

350  {
351  m_bIsDir = false;
352  size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
353  if (m_glob.gl_pathv[m_uiCurr][len - 1] == '/') {
354  m_bIsDir = true;
355  m_glob.gl_pathv[m_uiCurr][len - 1] = 0;
356  }
357  }
size_t m_uiCurr
Definition: SimpleGlob.h:418

◆ FindDone()

template<class SOCHAR >
void SimpleGlobBase< SOCHAR >::FindDone ( )
inline

Definition at line 388 of file SimpleGlob.h.

References memset().

388  {
389  globfree(&m_glob);
390  memset(&m_glob, 0, sizeof(m_glob));
391  m_uiCurr = (size_t) -1;
392  }
memset(buf, 0, buflen)
size_t m_uiCurr
Definition: SimpleGlob.h:418

◆ FindFirstFileS()

template<class SOCHAR >
int SimpleGlobBase< SOCHAR >::FindFirstFileS ( const char *  a_pszFileSpec,
unsigned int  a_uiFlags 
)
inline

Definition at line 359 of file SimpleGlob.h.

References SG_ERR_FAILURE, SG_ERR_MEMORY, SG_ERR_NOMATCH, SG_GLOB_ERR, SG_GLOB_TILDE, and SG_SUCCESS.

359  {
360  int nFlags = GLOB_MARK | GLOB_NOSORT;
361  if (a_uiFlags & SG_GLOB_ERR)
362  nFlags |= GLOB_ERR;
363 #ifdef GLOB_TILDE
364  if (a_uiFlags & SG_GLOB_TILDE)
365  nFlags |= GLOB_TILDE;
366 #endif
367  int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
368  if (rc == GLOB_NOSPACE)
369  return SG_ERR_MEMORY;
370  if (rc == GLOB_ABORTED)
371  return SG_ERR_FAILURE;
372  if (rc == GLOB_NOMATCH)
373  return SG_ERR_NOMATCH;
374  m_uiCurr = 0;
375  FilePrep();
376  return SG_SUCCESS;
377  }
void FilePrep()
Definition: SimpleGlob.h:350
size_t m_uiCurr
Definition: SimpleGlob.h:418

◆ FindNextFileS()

template<class SOCHAR >
bool SimpleGlobBase< SOCHAR >::FindNextFileS ( char  )
inline

Definition at line 379 of file SimpleGlob.h.

References SG_ASSERT.

379  {
380  SG_ASSERT(m_uiCurr != (size_t) -1);
381  if (++m_uiCurr >= m_glob.gl_pathc) {
382  return false;
383  }
384  FilePrep();
385  return true;
386  }
#define SG_ASSERT(b)
Definition: SimpleGlob.h:195
void FilePrep()
Definition: SimpleGlob.h:350
size_t m_uiCurr
Definition: SimpleGlob.h:418

◆ GetFileNameS()

template<class SOCHAR >
const char* SimpleGlobBase< SOCHAR >::GetFileNameS ( char  ) const
inline

Definition at line 394 of file SimpleGlob.h.

References SG_ASSERT.

394  {
395  SG_ASSERT(m_uiCurr != (size_t) -1);
396  return m_glob.gl_pathv[m_uiCurr];
397  }
#define SG_ASSERT(b)
Definition: SimpleGlob.h:195
size_t m_uiCurr
Definition: SimpleGlob.h:418

◆ GetFileTypeS()

template<class SOCHAR >
SG_FileType SimpleGlobBase< SOCHAR >::GetFileTypeS ( const char *  a_pszPath) const
inline

Definition at line 402 of file SimpleGlob.h.

References SG_FILETYPE_DIR, SG_FILETYPE_FILE, and SG_FILETYPE_INVALID.

402  {
403  struct stat sb;
404  if (0 != stat(a_pszPath, &sb)) {
405  return SG_FILETYPE_INVALID;
406  }
407  if (S_ISDIR(sb.st_mode)) {
408  return SG_FILETYPE_DIR;
409  }
410  if (S_ISREG(sb.st_mode)) {
411  return SG_FILETYPE_FILE;
412  }
413  return SG_FILETYPE_INVALID;
414  }

◆ IsDirS()

template<class SOCHAR >
bool SimpleGlobBase< SOCHAR >::IsDirS ( char  ) const
inline

Definition at line 398 of file SimpleGlob.h.

References SG_ASSERT.

398  {
399  SG_ASSERT(m_uiCurr != (size_t) -1);
400  return m_bIsDir;
401  }
#define SG_ASSERT(b)
Definition: SimpleGlob.h:195
size_t m_uiCurr
Definition: SimpleGlob.h:418

Field Documentation

◆ m_bIsDir

template<class SOCHAR >
bool SimpleGlobBase< SOCHAR >::m_bIsDir
private

Definition at line 419 of file SimpleGlob.h.

◆ m_glob

template<class SOCHAR >
glob_t SimpleGlobBase< SOCHAR >::m_glob
private

Definition at line 417 of file SimpleGlob.h.

◆ m_uiCurr

template<class SOCHAR >
size_t SimpleGlobBase< SOCHAR >::m_uiCurr
private

Definition at line 418 of file SimpleGlob.h.


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