bool traverse_dir(const string& path, vector<string>& files)
{
DIR *d;
struct dirent *file;
string traverse(std::move(path));
if (!(d = opendir(traverse.c_str())))
{
return false;
}
while ((file = readdir(d)) != NULL)
{
if (strncmp(file->d_name, ".", 1) == 0)
continue;
string fullname(path + "/" + file->d_name);
if (file->d_type & DT_DIR)
{
traverse_dir(fullname, files);
}
else
{
files.emplace_back(file->d_name);
}
}
closedir(d);
return true;
}