void DealFileInterfaceImpl::RecursionToFind(CString strTempPath,FILELIST& sfilelist)
{
CString strPath = strTempPath + ALL_FILE;
CString strTmp = _T("");
TARGETFILE sFile;
char* s_char = NULL;
CFileFind tempFind;
BOOL bFound;
bFound=tempFind.FindFile(strPath);
while(bFound) //遍历所有文件
{
bFound=tempFind.FindNextFile();
if(tempFind.IsDots()) //如果找到的是当前或者上层目录则结束本次查找
{
continue;
}
if(tempFind.IsDirectory()) //找到的是文件夹,则遍历该文件夹下的文件
{
//USES_CONVERSION;
//strTmp = tempFind.GetFileName();
//s_char = W2A(strTmp);
//sFile.strFileName = s_char;
strTmp=tempFind.GetFilePath();
//s_char=W2A(strTmp);
//sFile.strFilePath = s_char;
//sfilelist.push_back(sFile);
RecursionToFind(strTmp,sfilelist);//递归调用
}
else
{
USES_CONVERSION;
strTmp = tempFind.GetFileName();
s_char = W2A(strTmp);
sFile.strFileName = s_char;
strTmp=tempFind.GetFilePath();
s_char=W2A(strTmp);
sFile.strFilePath = s_char;
boost::hash<std::string> string_hash;
std::string strFileID = s_char;
sFile.ulFilesID = string_hash(strFileID);
s_char=W2A(CMD5Checksum::GetMD5(strTmp));
sFile.strFilesMD5 = s_char;
sfilelist.push_back(sFile);
}
}
tempFind.Close();
}
递归查找文件
最新推荐文章于 2024-03-29 23:26:40 发布