Ver Fonte

Merge branch 'master' of http://19.85.1.90:3000/Home/repos_util

Jeff há 9 meses atrás
pai
commit
9bdb81e222
1 ficheiros alterados com 14 adições e 2 exclusões
  1. 14 2
      gitver/gitver/gitver.cpp

+ 14 - 2
gitver/gitver/gitver.cpp

@@ -51,17 +51,26 @@ 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;
+	}
 
+	printf(_T("替换开始[%s]!\n"),lpFile);
 	DWORD dwFileLength = myFile.GetLength();
 	BYTE *pData = new BYTE[dwFileLength];
 	memset(pData, 0, dwFileLength);
@@ -81,16 +90,19 @@ 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();
 
-
 	return TRUE;
 }