Windows下_findnext()异常问题
_findnext()在调试时会出现异常现象,第一个参数”路径句柄”,返回的类型为intptr_t(long long),要改为long long或者intptr_t
//path 目录 filelist 文件列表 mode 文件名中的关键字
void filesearch(string path, vector<string>& filelist, string mode)
{
struct _finddata_t filefind;
if (path[path.size() - 1] == '\\')
path.resize(path.size() - 1);
string curr = path + "\\*.*";
int done = 0;
intptr_t handle = 0;
if ((handle = _findfirst(curr.c_str(), &filefind)) == -1)
return;
while (!(done = _findnext(handle, &filefind)))
{
if (!strcmp(filefind.name, ".."))
continue;
curr = path + "\\" + filefind.name;
if (_A_SUBDIR == filefind.attrib)
filesearch(curr, filelist, mode);
if (strstr(filefind.name, mode.c_str()))
filelist.push_back(curr);
}
_findclose(handle);
}