File: CWGlob.cc

package info (click to toggle)
craftywatcher 1.4-2
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 88 kB
  • ctags: 98
  • sloc: cpp: 660; makefile: 52
file content (53 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <string>
#include "CWGlob.h"

////////////////////////////////////////////////////////////////////////
// public
////////////////////////////////////////////////////////////////////////

CWGlob::CWGlob(const string& pattern, bool fMark, bool fSort)
  : _pattern(pattern)
{
  int flags = 0;
  if( fMark )
    flags |= GLOB_MARK;
  if( fSort )
    flags |= GLOB_NOSORT;

  switch( glob(_pattern.c_str(), flags, &GlobErr, &_results) )
    {
    case GLOB_NOSPACE:
      throw GLOB_NOSPACE;
      break;
      
    case GLOB_ABORTED:
      throw GLOB_ABORTED;
      break;
      
    default:
      break;
    };

  for(unsigned i = 0 ; i < _results.gl_pathc ; i++ )
    _path.push_back(_results.gl_pathv[i]);
}

CWGlob::~CWGlob()
{
  globfree(&_results);
}



////////////////////////////////////////////////////////////////////////
// protected
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
// private
////////////////////////////////////////////////////////////////////////

int CWGlob::GlobErr(const char * epath, int eerrno)
{
  return 0;  // continue globing.
}