|
@@ -51,16 +51,25 @@ void GetDirInfo()
|
|
|
BOOL ReplaceFileContent(LPCTSTR lpFile, std::vector<std::string> &vtOldContent, std::vector<std::string> &vtNewContent)
|
|
|
{
|
|
|
if ( vtOldContent.size() != vtNewContent.size() )
|
|
|
+ {
|
|
|
+ printf(_T("错误:替换内容空!\n"));
|
|
|
return FALSE;
|
|
|
+ }
|
|
|
|
|
|
if ( !PathFileExists(lpFile) )
|
|
|
+ {
|
|
|
+ printf(_T("错误:目标文件【%s】不存在!\n"), lpFile);
|
|
|
return FALSE;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
CFile myFile;
|
|
|
CFileException fileExp;
|
|
|
if ( !myFile.Open(lpFile, CFile::modeReadWrite, &fileExp) )
|
|
|
+ {
|
|
|
+ printf(_T("错误:打开目标文件【%s】失败!\n"), lpFile);
|
|
|
return FALSE;
|
|
|
+ }
|
|
|
|
|
|
DWORD dwFileLength = myFile.GetLength();
|
|
|
BYTE *pData = new BYTE[dwFileLength];
|
|
@@ -81,11 +90,15 @@ BOOL ReplaceFileContent(LPCTSTR lpFile, std::vector<std::string> &vtOldContent,
|
|
|
if ( nPos != std::string::npos )
|
|
|
{
|
|
|
strContent.replace(nPos, it_old->size(), it_new->c_str());
|
|
|
+ printf(_T("替换【%s】-【%s】成功\n"), it_old->c_str(), it_new->c_str());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ( !myFile.Open(lpFile, CFile::modeCreate|CFile::modeWrite, &fileExp) )
|
|
|
+ {
|
|
|
+ printf(_T("错误:保存目标文件【%s】失败!\n"), lpFile);
|
|
|
return FALSE;
|
|
|
+ }
|
|
|
|
|
|
myFile.Write(strContent.c_str(), strContent.size());
|
|
|
myFile.Close();
|