#include <regex>
#include <dirent.h>
#include <sys/types.h>
void getFiles(std::string path, vector<string>& files){
string path0 = path;
DIR* pDir;
struct dirent* ptr;
struct stat s;
lstat(path.c_str(), &s);
if(!S_ISDIR(s.st_mode)){
cout << "not a valid directory: " << path << endl;
return;
}
if(!(pDir = opendir(path.c_str()))){
cout << "opendir error: " << path << endl;
return;
}
int i = 0;
string subFile;
while((ptr = readdir(pDir)) != 0){
subFile = ptr -> d_name;
if(subFile == "." || subFile == "..")
continue;
subFile = path0 + subFile;
// cout << ++i << ": " << subFile << endl;
files.push_back(subFile);
}
closedir(pDir);
}