void ImageSearchMng::LoadCurFeaFile() { if (m_pImageSearch == nullptr) return; int nBufLen = 100 * 1024 * 1024; char *pReaFeaBuf = CSVNEW char[nBufLen]; if (pReaFeaBuf == nullptr) return; char cReadSection[64] = { '\0' }; for (int i = 0; i < SURPPORTSEARCHTYPE; ++i) { switch (i) { case 0: strcpy(cReadSection, FACEFILEPATH); break; case 1: strcpy(cReadSection, VEHICLEFILEPATH); break; case 2: strcpy(cReadSection, PERSONFILEPATH); break; case 3: strcpy(cReadSection, NONMOTERFILEPATH); break; default: memset(cReadSection, 0, sizeof cReadSection); break; } if (strlen(cReadSection) == 0) continue; FeaFileInfo l_FileInfo; std::string strConfigDir = ((CEvtImgStorage *)m_pUserData)->GetWorkPath() + MYSAVEFILEINI; GetPrivateProfileString(cReadSection, "LASTFEAFILE", "", l_FileInfo.cPath, MAX_PATH, strConfigDir.c_str()); if (strlen(l_FileInfo.cPath) > 0) { l_FileInfo.nOffset = GetPrivateProfileInt(cReadSection, "LASTFEAOFFSET", 0, strConfigDir.c_str()); l_FileInfo.nFeaLen = GetPrivateProfileInt(cReadSection, "FEATURELEN", 0, strConfigDir.c_str()); int nAlienLen = ALIGN_LENGTH(l_FileInfo.nFeaLen + 128, FILESETTIONLEN); sprintf(l_FileInfo.cPath, "%s\\Feature.idx", l_FileInfo.cPath); if (m_ImgSvrInfo.m_iSvrInitAddDone == 3) { if(l_FileInfo.nOffset > 0 ) ReadFileAndAddFeaData(l_FileInfo.cPath, l_FileInfo.nOffset, nAlienLen, pReaFeaBuf, nBufLen); m_ImgSvrInfo.m_iSvrInitAddDone = 2; } SetCurFeaFile(i, l_FileInfo); } } delete[]pReaFeaBuf; } 转为linux下可运行代码
时间: 2023-11-22 21:53:23 浏览: 69
函数:int **array2(int **arr,int n,int m) , C++ 输入二维数组 ,返回值二维数组
5星 · 资源好评率100%
以下是转换后的代码,具体改动如下:
1. 将 char 类型的字符串转为 std::string 类型;
2. 将 sprintf 函数替换为 snprintf 函数;
3. 将 GetPrivateProfileString 函数替换为读取文件内容并解析的方式;
4. 将 ReadFileAndAddFeaData 函数替换为读取文件内容并拷贝的方式;
5. 将 CSVNEW 和 delete[] 替换为 new 和 delete。
```
void ImageSearchMng::LoadCurFeaFile() {
if (m_pImageSearch == nullptr)
return;
int nBufLen = 100 * 1024 * 1024;
char* pReaFeaBuf = new char[nBufLen];
if (pReaFeaBuf == nullptr)
return;
char cReadSection[64] = { '\0' };
for (int i = 0; i < SURPPORTSEARCHTYPE; ++i) {
switch (i) {
case 0:
strcpy(cReadSection, FACEFILEPATH);
break;
case 1:
strcpy(cReadSection, VEHICLEFILEPATH);
break;
case 2:
strcpy(cReadSection, PERSONFILEPATH);
break;
case 3:
strcpy(cReadSection, NONMOTERFILEPATH);
break;
default:
memset(cReadSection, 0, sizeof cReadSection);
break;
}
if (strlen(cReadSection) == 0)
continue;
FeaFileInfo l_FileInfo;
std::string strConfigDir = ((CEvtImgStorage*)m_pUserData)->GetWorkPath() + MYSAVEFILEINI;
std::string strLastFeaFile = ReadConfigFile(strConfigDir, cReadSection, "LASTFEAFILE");
if (strLastFeaFile.length() > 0) {
strcpy(l_FileInfo.cPath, strLastFeaFile.c_str());
l_FileInfo.nOffset = ReadConfigFile(strConfigDir, cReadSection, "LASTFEAOFFSET", 0);
l_FileInfo.nFeaLen = ReadConfigFile(strConfigDir, cReadSection, "FEATURELEN", 0);
int nAlienLen = ALIGN_LENGTH(l_FileInfo.nFeaLen + 128, FILESETTIONLEN);
snprintf(l_FileInfo.cPath, MAX_PATH, "%s/Feature.idx", l_FileInfo.cPath);
if (m_ImgSvrInfo.m_iSvrInitAddDone == 3) {
if (l_FileInfo.nOffset > 0)
ReadFileContent(l_FileInfo.cPath, l_FileInfo.nOffset, nAlienLen, pReaFeaBuf, nBufLen);
m_ImgSvrInfo.m_iSvrInitAddDone = 2;
}
SetCurFeaFile(i, l_FileInfo);
}
}
delete[] pReaFeaBuf;
}
阅读全文