Skip to content

Instantly share code, notes, and snippets.

@piti118
Created December 22, 2011 16:25
Show Gist options
  • Save piti118/1510882 to your computer and use it in GitHub Desktop.
Save piti118/1510882 to your computer and use it in GitHub Desktop.
An STL glob wrapper for linux and mac
#include <glob.h>
#include <vector>
#include <string>
inline std::vector<std::string> glob(const std::string& pat){
using namespace std;
glob_t glob_result;
glob(pat.c_str(),GLOB_TILDE,NULL,&glob_result);
vector<string> ret;
for(unsigned int i=0;i<glob_result.gl_pathc;++i){
ret.push_back(string(glob_result.gl_pathv[i]));
}
globfree(&glob_result);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment