Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

SimpleGlobBase< SOCHAR > Struct Template Reference

#include <SimpleGlob.h>

Inheritance diagram for SimpleGlobBase< SOCHAR >:

Inheritance graph
[legend]

Detailed Description

template<class SOCHAR>
struct SimpleGlobBase< SOCHAR >

Unix glob implementation.


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


Constructor & Destructor Documentation

template<class SOCHAR>
SimpleGlobBase< SOCHAR >::SimpleGlobBase  )  [inline]
 

00339                          {
00340                 memset(&m_glob, 0, sizeof(m_glob));
00341                 m_uiCurr = (size_t) -1;
00342         }             ~SimpleGlobBase() {

template<class SOCHAR>
SimpleGlobBase< SOCHAR >::~SimpleGlobBase  )  [inline]
 

00342                                         {
00343                 globfree(&m_glob);
00344         }


Member Function Documentation

template<class SOCHAR>
void SimpleGlobBase< SOCHAR >::FilePrep  )  [inline]
 

00346                         {
00347                 m_bIsDir = false;
00348                 size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
00349                 if (m_glob.gl_pathv[m_uiCurr][len - 1] == '/') {
00350                         m_bIsDir = true;
00351                         m_glob.gl_pathv[m_uiCurr][len - 1] = 0;
00352                 }
00353         }

template<class SOCHAR>
void SimpleGlobBase< SOCHAR >::FindDone  )  [inline]
 

00384                         {
00385                 globfree(&m_glob);
00386                 memset(&m_glob, 0, sizeof(m_glob));
00387                 m_uiCurr = (size_t) -1;
00388         }

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

00355                                                                               {
00356                 int nFlags = GLOB_MARK | GLOB_NOSORT;
00357                 if (a_uiFlags & SG_GLOB_ERR)
00358                         nFlags |= GLOB_ERR;
00359 #ifdef GLOB_TILDE
00360                 if (a_uiFlags & SG_GLOB_TILDE)
00361                         nFlags |= GLOB_TILDE;
00362 #endif
00363                 int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
00364                 if (rc == GLOB_NOSPACE)
00365                         return SG_ERR_MEMORY;
00366                 if (rc == GLOB_ABORTED)
00367                         return SG_ERR_FAILURE;
00368                 if (rc == GLOB_NOMATCH)
00369                         return SG_ERR_NOMATCH;
00370                 m_uiCurr = 0;
00371                 FilePrep();
00372                 return SG_SUCCESS;
00373         }

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

00375                                  {
00376                 SG_ASSERT(m_uiCurr != (size_t) -1);
00377                 if (++m_uiCurr >= m_glob.gl_pathc) {
00378                         return false;
00379                 }
00380                 FilePrep();
00381                 return true;
00382         }

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

00390                                              {
00391                 SG_ASSERT(m_uiCurr != (size_t) -1);
00392                 return m_glob.gl_pathv[m_uiCurr];
00393         } bool IsDirS(char) const {

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

00396                                                                 {
00397                 struct stat sb;
00398                 if   (0 != stat(a_pszPath, &sb)) {
00399                         return SG_FILETYPE_INVALID;
00400                 }
00401                 if    (S_ISDIR(sb.st_mode)) {
00402                         return SG_FILETYPE_DIR;
00403                 }
00404                 if (S_ISREG(sb.st_mode)) {
00405                         return SG_FILETYPE_FILE;
00406                 }
00407                 return SG_FILETYPE_INVALID;
00408         }

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

00393                                   {
00394                 SG_ASSERT(m_uiCurr != (size_t) -1);
00395                 return m_bIsDir;
00396         } SG_FileType GetFileTypeS(const char *a_pszPath) const {


The documentation for this struct was generated from the following file:
Generated on Fri Oct 10 11:24:17 2008 for FreeSWITCH by  doxygen 1.3.9.1