|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
while (getline(InputFile, line)) {
cout<<"enter successful"<<endl;
size_t commaPos = line.find(L',');
if (commaPos != wstring::npos) {
wstring keyword = Trim(line.substr(0, commaPos));
wstring wFilePath = Trim(line.substr(commaPos + 1));
string filePath(wFilePath.begin(), wFilePath.end());
// 替换路径中的反斜杠
filePath = ReplaceBackslashWithSlash(filePath);
// 检查 CSV 中的关键词是否在用户关键词列表中
if (find(UKeyWords.begin(), UKeyWords.end(), keyword) != UKeyWords.end()) {
wcout << "找到匹配关键词: " << keyword << endl;
// 获取文件信息
int fileSizeBytes = GetSizeBytes(filePath); // 以字节获取文件大小
pair<string, time_t> timeInfo = GetTime(filePath);
string fileTime = timeInfo.first;
time_t rawTime = timeInfo.second;
// 如果文件存在且可访问,保存文件信息
if (fileSizeBytes != -1 && rawTime != -1) {
matchedFiles.emplace_back(filePath, fileSizeBytes, fileTime, rawTime);
wcout << "文件路径: " << wFilePath << ", 大小: " << fileSizeBytes << " B, 修改时间: " << StringToWString(fileTime) << endl;
}
else {
wcerr << "无法访问文件: " << wFilePath << endl;
}
}
}
} |
|