| 1 | #include "cvd/diskbuffer2.h" |
| 2 | #include "cvd_src/config_internal.h" |
| 3 | #include <glob.h> |
| 4 | #include <string> |
| 5 | #include <vector> |
| 6 | |
| 7 | using namespace std; |
| 8 | using namespace CVD; |
| 9 | |
| 10 | // |
| 11 | // GLOBLIST |
| 12 | // Makes a list of files matching a pattern |
| 13 | // |
| 14 | namespace CVD |
| 15 | { |
| 16 | vector<string> globlist(const string& gl) |
| 17 | { |
| 18 | vector<string> ret; |
| 19 | |
| 20 | glob_t g; |
| 21 | unsigned int i; |
| 22 | |
| 23 | #ifdef CVD_INTERNAL_GLOB_IS_BAD |
| 24 | glob(gl.c_str(), 0, 0, &g); |
| 25 | #else |
| 26 | glob(gl.c_str(), GLOB_BRACE | GLOB_TILDE, 0, &g); |
| 27 | #endif |
| 28 | |
| 29 | for(i = 0; i < g.gl_pathc; i++) |
| 30 | ret.push_back(g.gl_pathv[i]); |
| 31 | |
| 32 | globfree(&g); |
| 33 | |
| 34 | if(ret.size() == 1 && ret[0] == "") |
| 35 | ret.resize(0); |
| 36 | |
| 37 | return ret; |
| 38 | } |
| 39 | } |