SimpleOpt
Classes | Macros | Typedefs | Enumerations
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...

Go to the source code of this file.

Classes

class  CSimpleGlobTempl< SOCHAR >
 Implementation of the SimpleGlob class. More...
 

Macros

#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
 The operation of SimpleGlob is fine-tuned via the use of a combination of the following flags. More...
 
enum  SG_Error
 Error return codes.
 

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

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 SimpleGlob.h.

Enumeration Type Documentation

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_ERRReturn upon read error (e.g. directory does not have read permission)
SG_GLOB_MARKAppend a slash (backslash in Windows) to every path which corresponds to a directory
SG_GLOB_NOSORTBy 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_FULLSORTBy 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_NOCHECKIf the pattern doesn't match anything, return the original pattern.
SG_GLOB_TILDETilde expansion is carried out (on Unix platforms)
SG_GLOB_ONLYDIRReturn only directories which match (not compatible with SG_GLOB_ONLYFILE)
SG_GLOB_ONLYFILEReturn only files which match (not compatible with SG_GLOB_ONLYDIR)
SG_GLOB_NODOTDo not return the "." or ".." special directories.

Definition at line 129 of file SimpleGlob.h.