-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlob.hh
More file actions
49 lines (35 loc) · 680 Bytes
/
Glob.hh
File metadata and controls
49 lines (35 loc) · 680 Bytes
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
/* Copyright 2005 - 2007 René Rebe - ExactCODE GmbH */
#ifndef UTILITY__GLOB_HH__
#define UTILITY__GLOB_HH__
#include <glob.h>
#include <string>
namespace Utility
{
/* very lightweight glob wrapper ... */
class Glob
{
public:
typedef char** iterator;
Glob (const std::string& pattern, int flags = 0) {
glob (pattern.c_str(), flags, NULL, &g);
}
~Glob () {
globfree (&g);
}
iterator begin() {
return g.gl_pathv;
}
iterator end() {
return g.gl_pathv + g.gl_pathc;
}
operator void*() {
return g.gl_pathc == 0 ? 0 : this;
}
bool operator!() const {
return g.gl_pathc == 0;
}
private:
glob_t g;
};
}
#endif