![]() |
#2
rjsp2022-08-14 10:06
|

vector<string> files;
GetAllFiles(".", files, ".txt"); // 到这里是正常的
for (int j = 1; j < argc; j++) {
printf("loading dir %s \n", argv[j]);
GetAllFiles(string(argv[j]), files, ".txt"); // 这里就不行了,提示page fault,不知道是代码写的不对还是我机器本身的bug
}

void GetAllFiles(string path, vector<string> &files, string fileType) {
long hFile = 0;
_finddata_t fileinfo;
string p;
if ((hFile = _findfirst(p.assign(path).append("\\*" + fileType).c_str(), &fileinfo)) != -1) {
while (true) {
files.push_back(p.assign(path).append("\\").append(fileinfo.name));
int status = _findnext(hFile, &fileinfo);
if (status == -1) break;
}
_findclose(hFile);
}
}