소스 검색

Z991239-5625 #comment 哈希上送和文件大小计算位置调整

80374374 1 년 전
부모
커밋
18a27a26aa
2개의 변경된 파일25개의 추가작업 그리고 24개의 파일을 삭제
  1. 23 0
      Module/include/CommEntityUtil.hpp
  2. 2 24
      Module/mod_gpio/mod_gpio.cpp

+ 23 - 0
Module/include/CommEntityUtil.hpp

@@ -1159,6 +1159,29 @@ static std::string GetWWWInfoThroughDig(const std::string& wwwUrl)
 
 }//Net
 
+namespace FileSystem {
+
+	static DWORD FetchFileSize(const char* filePath)
+	{
+		int fileSize = 0;
+#if defined(RVC_OS_LINUX)
+		struct stat statbuf;
+		ZeroMemory(&statbuf, sizeof(statbuf));
+		stat(filePath, &statbuf);
+		fileSize = statbuf.st_size;
+#else
+		
+		HANDLE hFile;
+		hFile = CreateFile(filePath, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		if (hFile != INVALID_HANDLE_VALUE) {
+			fileSize = GetFileSize(hFile, NULL);
+			CloseHandle(hFile);
+		}
+#endif //RVC_OS_LINUX
+		return fileSize;
+	}
+}
+
 } // mod
 } // sp
 

+ 2 - 24
Module/mod_gpio/mod_gpio.cpp

@@ -258,7 +258,6 @@ struct GpioInitTask : public ITaskSp {
 
 void CGpioEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
 {
-	LOG_FUNCTION();
 	GpioInitTask* initTask = new GpioInitTask(this, pTransactionContext);
 	GetFunction()->PostThreadPoolTask(initTask);
 }
@@ -266,34 +265,14 @@ void CGpioEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<I
 void CGpioEntity::ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo)
 {
 	LOG_FUNCTION();
-	CSmartPointer<IConfigInfo> spConfigRoot;
-	GetFunction()->OpenConfig(Config_Root, spConfigRoot);
-	CSimpleStringA csEnvCamera(""), csOptCamera, csOSVerion, csWarnMsg("");
-
 	//calculate file hash value
 	std::map<std::string, std::string> termInfo;
 	char* strFileHash = new char[128];
 	ZeroMemory(strFileHash, 128);
 	BYTE fileHash[32];
-	SM3File(const_cast<char*>(m_adapterInfo.adapterFileName.GetData()), fileHash);
+	SM3File(const_cast<char*>(m_adapterInfo.adapterFilePath.GetData()), fileHash);
     SP::Module::Util::HexBuf2StrBuf(fileHash, &strFileHash, 32);
-
-	//calculate file size
-#if defined(RVC_OS_LINUX)
-    struct stat statbuf;
-    ZeroMemory(&statbuf, sizeof(statbuf));
-    stat(m_adapterInfo.adapterFilePath.GetData(), &statbuf);
-    int fileSize = statbuf.st_size;
-#else
-    int fileSize = 0;
-    HANDLE hFile;
-    hFile = CreateFile(m_adapterInfo.adapterFilePath.GetData(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-    if (hFile != INVALID_HANDLE_VALUE) {
-        fileSize = GetFileSize(hFile, NULL);
-        CloseHandle(hFile);
-    }
-#endif //RVC_OS_LINUX
-
+    DWORD fileSize = SP::Module::FileSystem::FetchFileSize(m_adapterInfo.adapterFilePath);
 	termInfo["VendorDllName"] = m_adapterInfo.adapterFileName;
 	termInfo["VendorDllFileHash"] = strFileHash;
 	ZeroMemory(strFileHash, 128);
@@ -311,7 +290,6 @@ void CGpioEntity::ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo)
 	std::pair<bool, std::string> strResult;
 	strResult = generateJsonStr(termInfo);
 	LogWarn(Severity_Low, Error_Unexpect, GPIO_UserErrorCode_LogInfoAboutTerm, strResult.second.c_str());
-
 	return;
 }