Created
June 26, 2015 16:18
-
-
Save lucianmachado/9a26d5745497ffe5d054 to your computer and use it in GitHub Desktop.
Glob C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Thank you - this looks very useful! What is the license?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could this be updated to check for errors, similar to this link: https://stackoverflow.com/questions/8401777/simple-glob-in-c-on-unix-system