|
@@ -96,6 +96,53 @@ again:
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
+ std::string GetFileData(LPCTSTR lpFile)
|
|
|
+ {
|
|
|
+ if ( !lpFile || lpFile[0] == '\0' || !PathFileExists(lpFile) )
|
|
|
+ return std::string();
|
|
|
+
|
|
|
+ CFile file;
|
|
|
+ CFileException exp;
|
|
|
+ if ( file.Open(lpFile, CFile::modeRead, &exp) )
|
|
|
+ {
|
|
|
+ DWORD dwRead = 0;
|
|
|
+ DWORD dwCount = 0;
|
|
|
+ std::string strData;
|
|
|
+ char szRead[MAX_PATH] = {0};
|
|
|
+ DWORD dwLen = file.GetLength();
|
|
|
+ while ( dwCount < dwLen )
|
|
|
+ {
|
|
|
+ dwRead = file.Read(szRead, MAX_PATH);
|
|
|
+ strData.append(szRead, dwRead);
|
|
|
+ dwCount += dwRead;
|
|
|
+ }
|
|
|
+
|
|
|
+ file.Close();
|
|
|
+
|
|
|
+ return strData;
|
|
|
+ }
|
|
|
+
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string GetFileLine(std::string &strFileData, int nLine)
|
|
|
+ {
|
|
|
+ int nPos=0;
|
|
|
+ int nIndex = 0;
|
|
|
+ std::string strTemp = strFileData;
|
|
|
+ while ( (nPos=strTemp.find('\r\n')) != std::string::npos )
|
|
|
+ {
|
|
|
+ if ( nIndex++ == nLine )
|
|
|
+ {
|
|
|
+ strTemp = strTemp.substr(0, nPos);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ strTemp = strTemp.substr(nPos+2);
|
|
|
+ }
|
|
|
+
|
|
|
+ return nIndex < nLine ? std::string() : strTemp;
|
|
|
+ }
|
|
|
+
|
|
|
DWORD FindProcess(LPCTSTR lpProName)
|
|
|
{
|
|
|
ASSERT(lpProName!=NULL);
|