SimpleGlob.h File Reference

A cross-platform file globbing library providing the ability to expand wildcards in command-line arguments to a list of all matching files. It is designed explicitly to be portable to any platform and has been tested on Windows and Linux. See CSimpleGlobTempl for the class definition. More...

#include <sys/types.h>
#include <sys/stat.h>
#include <glob.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>

Include dependency graph for SimpleGlob.h:

Go to the source code of this file.

Data Structures

class  SimpleGlobUtil
 String manipulation functions. More...
struct  SimpleGlobBase< SOCHAR >
 Unix glob implementation. More...
class  CSimpleGlobTempl< SOCHAR >
 Implementation of the SimpleGlob class. More...

Defines

#define MAX_PATH   PATH_MAX
#define sg_strchr   ::strchr
#define sg_strrchr   ::strrchr
#define sg_strlen   ::strlen
#define sg_strcpy_s(a, n, b)   ::strcpy(a,b)
#define sg_strcmp   ::strcmp
#define sg_strcasecmp   ::strcasecmp
#define SOCHAR_T   char
#define SG_ASSERT(b)
#define SG_PATH_CHAR   '/'
#define CSimpleGlob   CSimpleGlobA
 TCHAR version dependent on if _UNICODE is defined.

Typedefs

typedef CSimpleGlobTempl<
char > 
CSimpleGlobA
 ASCII/MBCS version of CSimpleGlob.
typedef CSimpleGlobTempl<
wchar_t > 
CSimpleGlobW
 wchar_t version of CSimpleGlob

Enumerations

enum  SG_Flags {
  SG_GLOB_ERR = 1 << 0, SG_GLOB_MARK = 1 << 1, SG_GLOB_NOSORT = 1 << 2, SG_GLOB_NOCHECK = 1 << 3,
  SG_GLOB_TILDE = 1 << 4, SG_GLOB_ONLYDIR = 1 << 5, SG_GLOB_ONLYFILE = 1 << 6, SG_GLOB_NODOT = 1 << 7,
  SG_GLOB_FULLSORT = 1 << 8
}
 The operation of SimpleGlob is fine-tuned via the use of a combination of the following flags. More...
enum  SG_Error { SG_SUCCESS = 0, SG_ERR_NOMATCH = 1, SG_ERR_MEMORY = -1, SG_ERR_FAILURE = -2 }
 Error return codes. More...
enum  SG_FileType { SG_FILETYPE_INVALID, SG_FILETYPE_FILE, SG_FILETYPE_DIR }


Detailed Description

A cross-platform file globbing library providing the ability to expand wildcards in command-line arguments to a list of all matching files. It is designed explicitly to be portable to any platform and has been tested on Windows and Linux. See CSimpleGlobTempl for the class definition.

Version:
2.8

FEATURES

USAGE

The SimpleGlob class is used by following these steps:

  1. Include the SimpleGlob.h header file

            #include "SimpleGlob.h"
            

  2. Instantiate a CSimpleGlob object supplying the appropriate flags.

             CSimpleGlob  glob(FLAGS);
            

  3. Add all file specifications to the glob class.

            glob.Add("file*");
            glob.Add(argc, argv);
            

  4. Process all files with File(), Files() and FileCount()

            for (int n = 0; n < glob.FileCount(); ++n) {
                ProcessFile(glob.File(n));
            }
            

MIT LICENCE

The licence text below is the boilerplate "MIT Licence" used from: http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2006-2007, Brodie Thiesfield

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file SimpleGlob.h.


Define Documentation

#define CSimpleGlob   CSimpleGlobA

TCHAR version dependent on if _UNICODE is defined.

Definition at line 790 of file SimpleGlob.h.

#define MAX_PATH   PATH_MAX

Definition at line 171 of file SimpleGlob.h.

Referenced by CSimpleGlobTempl< SOCHAR >::Add().

#define SG_ASSERT (  ) 

Definition at line 195 of file SimpleGlob.h.

Referenced by CSimpleGlobTempl< SOCHAR >::File(), SimpleGlobBase< SOCHAR >::FindNextFileS(), SimpleGlobBase< SOCHAR >::GetFileNameS(), SimpleGlobBase< SOCHAR >::IsDirS(), and CSimpleGlobTempl< SOCHAR >::SetArgvArrayType().

#define SG_PATH_CHAR   '/'

Definition at line 339 of file SimpleGlob.h.

Referenced by CSimpleGlobTempl< SOCHAR >::Add(), and CSimpleGlobTempl< SOCHAR >::AppendName().

#define sg_strcasecmp   ::strcasecmp

Definition at line 177 of file SimpleGlob.h.

Referenced by SimpleGlobUtil::strcasecmp().

#define sg_strchr   ::strchr

Definition at line 172 of file SimpleGlob.h.

Referenced by SimpleGlobUtil::strchr().

#define sg_strcmp   ::strcmp

Definition at line 176 of file SimpleGlob.h.

Referenced by SimpleGlobUtil::strcmp().

#define sg_strcpy_s ( a,
n,
 )     ::strcpy(a,b)

Definition at line 175 of file SimpleGlob.h.

Referenced by SimpleGlobUtil::strcpy_s().

#define sg_strlen   ::strlen

Definition at line 174 of file SimpleGlob.h.

#define sg_strrchr   ::strrchr

Definition at line 173 of file SimpleGlob.h.

Referenced by SimpleGlobUtil::strrchr().

#define SOCHAR_T   char

Definition at line 178 of file SimpleGlob.h.

Referenced by SimpleGlobUtil::strcasecmp(), SimpleGlobUtil::strchr(), SimpleGlobUtil::strcmp(), SimpleGlobUtil::strcpy_s(), and SimpleGlobUtil::strrchr().


Typedef Documentation

typedef CSimpleGlobTempl< char > CSimpleGlobA

ASCII/MBCS version of CSimpleGlob.

Definition at line 785 of file SimpleGlob.h.

typedef CSimpleGlobTempl< wchar_t > CSimpleGlobW

wchar_t version of CSimpleGlob

Definition at line 786 of file SimpleGlob.h.


Enumeration Type Documentation

enum SG_Error

Error return codes.

Enumerator:
SG_SUCCESS 
SG_ERR_NOMATCH 
SG_ERR_MEMORY 
SG_ERR_FAILURE 

Definition at line 138 of file SimpleGlob.h.

00138               {
00139         SG_SUCCESS = 0,
00140         SG_ERR_NOMATCH = 1,
00141         SG_ERR_MEMORY = -1,
00142         SG_ERR_FAILURE = -2
00143 };

enum SG_FileType

Enumerator:
SG_FILETYPE_INVALID 
SG_FILETYPE_FILE 
SG_FILETYPE_DIR 

Definition at line 252 of file SimpleGlob.h.

00252                  {
00253         SG_FILETYPE_INVALID,
00254         SG_FILETYPE_FILE,
00255         SG_FILETYPE_DIR
00256 };

enum SG_Flags

The operation of SimpleGlob is fine-tuned via the use of a combination of the following flags.

The flags may be passed at initialization of the class and used for every filespec added, or alternatively they may optionally be specified in the call to Add() and be different for each filespec.

Parameters:
SG_GLOB_ERR Return upon read error (e.g. directory does not have read permission)
SG_GLOB_MARK Append a slash (backslash in Windows) to every path which corresponds to a directory
SG_GLOB_NOSORT By default, files are returned in sorted into string order. With this flag, no sorting is done. This is not compatible with SG_GLOB_FULLSORT.
SG_GLOB_FULLSORT By default, files are sorted in groups belonging to each filespec that was added. For example if the filespec "b*" was added before the filespec "a*" then the argv array will contain all b* files sorted in order, followed by all a* files sorted in order. If this flag is specified, the entire array will be sorted ignoring the filespec groups.
SG_GLOB_NOCHECK If the pattern doesn't match anything, return the original pattern.
SG_GLOB_TILDE Tilde expansion is carried out (on Unix platforms)
SG_GLOB_ONLYDIR Return only directories which match (not compatible with SG_GLOB_ONLYFILE)
SG_GLOB_ONLYFILE Return only files which match (not compatible with SG_GLOB_ONLYDIR)
SG_GLOB_NODOT Do not return the "." or ".." special directories.
Enumerator:
SG_GLOB_ERR 
SG_GLOB_MARK 
SG_GLOB_NOSORT 
SG_GLOB_NOCHECK 
SG_GLOB_TILDE 
SG_GLOB_ONLYDIR 
SG_GLOB_ONLYFILE 
SG_GLOB_NODOT 
SG_GLOB_FULLSORT 

Definition at line 125 of file SimpleGlob.h.

00125               {
00126         SG_GLOB_ERR = 1 << 0,
00127         SG_GLOB_MARK = 1 << 1,
00128         SG_GLOB_NOSORT = 1 << 2,
00129         SG_GLOB_NOCHECK = 1 << 3,
00130         SG_GLOB_TILDE = 1 << 4,
00131         SG_GLOB_ONLYDIR = 1 << 5,
00132         SG_GLOB_ONLYFILE = 1 << 6,
00133         SG_GLOB_NODOT = 1 << 7,
00134         SG_GLOB_FULLSORT = 1 << 8
00135 };


Generated on Wed May 16 04:00:07 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7