Thrill  0.1
simple_glob.hpp 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 <climits>
#include <glob.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <wchar.h>
#include <cstdlib>
#include <cstring>
+ Include dependency graph for simple_glob.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

 thrill
 
 thrill::vfs
 
 thrill::vfs::glob_local
 

Macros

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

Typedefs

using CSimpleGlobA = CSimpleGlobTempl< char >
 ASCII/MBCS version of CSimpleGlob. More...
 
using CSimpleGlobW = CSimpleGlobTempl< wchar_t >
 wchar_t version of CSimpleGlob More...
 

Enumerations

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 }
 
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...
 

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
3.6

FEATURES

  • MIT Licence allows free use in all software (including GPL and commercial)
  • multi-platform (Windows 95/98/ME/NT/2K/XP, Linux, Unix)
  • supports most of the standard linux glob() options
  • recognition of a forward paths as equivalent to a backward slash on Windows. e.g. "c:/path/foo*" is equivalent to "c:\path\foo*".
  • implemented with only a single C++ header file
  • char, wchar_t and Windows TCHAR in the same program
  • complete working examples included
  • compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning level 3 (Windows/VC6) and -Wall (Linux/gcc)

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-2013, 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 simple_glob.hpp.

Macro Definition Documentation

◆ CSimpleGlob

#define CSimpleGlob   CSimpleGlobA

TCHAR version dependent on if _UNICODE is defined.

Definition at line 974 of file simple_glob.hpp.

Referenced by thrill::vfs::SysGlob().

◆ MAX_PATH

#define MAX_PATH   PATH_MAX

Definition at line 57 of file simple_glob.hpp.

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

◆ SG_ASSERT

◆ SG_HAVE_ICU

#define SG_HAVE_ICU   0

Definition at line 29 of file simple_glob.hpp.

◆ SG_PATH_CHAR

#define SG_PATH_CHAR   '/'

◆ sg_strcasecmp

#define sg_strcasecmp   ::strcasecmp

Definition at line 63 of file simple_glob.hpp.

Referenced by SimpleGlobUtil::strcasecmp().

◆ sg_strchr

#define sg_strchr   ::strchr

Definition at line 58 of file simple_glob.hpp.

Referenced by SimpleGlobUtil::strchr().

◆ sg_strcmp

#define sg_strcmp   ::strcmp

Definition at line 62 of file simple_glob.hpp.

Referenced by SimpleGlobUtil::strcmp().

◆ sg_strcpy_s

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

Definition at line 61 of file simple_glob.hpp.

Referenced by SimpleGlobUtil::strcpy_s().

◆ sg_strlen

#define sg_strlen   ::strlen

Definition at line 60 of file simple_glob.hpp.

◆ sg_strrchr

#define sg_strrchr   ::strrchr

Definition at line 59 of file simple_glob.hpp.

Referenced by SimpleGlobUtil::strrchr().

◆ SOCHAR_T

#define SOCHAR_T   char

Definition at line 64 of file simple_glob.hpp.

Referenced by SimpleGlobUtil::strcasecmp(), and SimpleGlobUtil::strcmp().

◆ THRILL_VFS_SIMPLE_GLOB_HEADER

#define THRILL_VFS_SIMPLE_GLOB_HEADER

Definition at line 18 of file simple_glob.hpp.