Ver código fonte

Z991239-5719 #comment 移除不再使用的代码函数

80374374 11 meses atrás
pai
commit
9e12c3d633

+ 0 - 326
Framework/spbase/SpEntityPrivilege.cpp

@@ -329,81 +329,6 @@ ErrorCodeEnum SpEntityPrivilege::Reboot(RebootTriggerEnum eTriggerReason,RebootW
 	return Error;
 }
 
-bool SpEntityPrivilege::RecursiveCopyDir(const char *pszSourceDir, const char *pszDestDir, CSimpleStringA& strErrInfo)
-{
-	array_header_t *arr;
-	
-	if (!ExistsDirA(pszSourceDir))
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("source dir [%s] not exists", pszSourceDir);
-		return false;
-	}
-
-	if (!ExistsDirA(pszDestDir))
-	{
-		if (!CreateDirRecursiveA(pszDestDir))
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("create dir [%s] fail: %d", pszDestDir, GetLastError());
-			return false;
-		}
-
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("create dir [%s] succ", pszDestDir);
-	}
-
-	arr = fileutil_get_sub_files_a(pszSourceDir);
-	if (arr)
-	{
-		int i;
-		for (i = 0; i < arr->nelts; ++i)
-		{
-			char szDestFile[256] = { 0 };
-			char *file = ARRAY_IDX(arr, i, char*);
-			strcpy(szDestFile, pszDestDir);
-			if (szDestFile[strlen(szDestFile) - 1] != SPLIT_SLASH)
-				strcat(szDestFile, SPLIT_SLASH_STR);
-			strcat(szDestFile, strrchr(file, SPLIT_SLASH) + 1);
-
-			if (!CopyFileA(file, szDestFile, FALSE))
-			{
-				strErrInfo = CSimpleStringA::Format("copy file [%s] fail: %d", file, GetLastError());
-				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("copy file [%s] fail: %d", file, GetLastError());
-				toolkit_array_free2(arr);
-				return false;
-			}
-
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("copy file [%s] succ", file);
-		}
-		toolkit_array_free2(arr);
-	}
-
-	arr = fileutil_get_sub_dirs_a(pszSourceDir);
-	if (arr)
-	{
-		int i;
-		for (i = 0; i < arr->nelts; ++i)
-		{
-			char szDestSubDir[256] = { 0 };
-			char *dir = ARRAY_IDX(arr, i, char*);
-			strcpy(szDestSubDir, pszDestDir);
-			if (szDestSubDir[strlen(szDestSubDir) - 1] != SPLIT_SLASH)
-				strcat(szDestSubDir, SPLIT_SLASH_STR);
-			strcat(szDestSubDir, strrchr(dir, SPLIT_SLASH) + 1);
-
-			if (!RecursiveCopyDir(dir, szDestSubDir, strErrInfo))
-			{
-				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("copy dir [%s] fail: %d", dir, GetLastError());
-				toolkit_array_free2(arr);
-				return false;
-			}
-
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("copy dir [%s] succ", dir);
-		}
-		toolkit_array_free2(arr);
-	}
-
-	return true;
-}
-
 ErrorCodeEnum SpEntityPrivilege::UpdateVerTxt(const char* strActiveFilePath, const char* toWriteVersionStr, bool toCheck)
 {
 	HANDLE hFile = ::CreateFileA(strActiveFilePath, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -470,257 +395,6 @@ ErrorCodeEnum SpEntityPrivilege::UpdateVerTxt(const char* strActiveFilePath, con
 	return bSetSucc ? Error_Succeed : Error_Unexpect;
 }
 
-ErrorCodeEnum CopyFolder(CSimpleStringA strSourcePath, CSimpleStringA strDestPath)
-{
-	if (strSourcePath.IsNullOrEmpty() || strDestPath.IsNullOrEmpty())
-	{
-		return Error_Null;
-	}
-	
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Start to copy dir %s to dir %s", (const char*)strSourcePath,(const char*)strDestPath);
-
-
-#ifdef _WIN32
-	_finddata_t FileInfo;
-	CSimpleStringA strfind = strSourcePath + "\\*";
-	long Handle = _findfirst(strfind, &FileInfo);
-	if (-1L == Handle)
-	{
-		_findclose(Handle);
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s文件夹为空", strSourcePath);
-		return Error_Succeed;
-	}
-
-	CSimpleStringA newPath;
-
-	do{
-		if (FileInfo.attrib & _A_SUBDIR)
-		{
-			if ((strcmp(FileInfo.name, ".") != 0) && (strcmp(FileInfo.name, "..") != 0))
-			{
-				newPath = strSourcePath + "\\" + FileInfo.name;
-				CSimpleStringA newDestPath = strDestPath + "\\" + FileInfo.name;
-				
-				/*if (strcmp(FileInfo.name, "") == 0)
-				{
-				continue;
-				}*/
-
-				if (!ExistsDirA(newDestPath))
-				{
-					CreateDirA(newDestPath, TRUE);
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Create Dir %s success", (const char*)newDestPath);
-				}
-				
-				CopyFolder(newPath, newDestPath);
-			}
-		}
-		else
-		{			
-			CSimpleStringA strFindName = FileInfo.name;
-			{
-				CSimpleStringA strSourceFile = strSourcePath + "\\" + strFindName;
-				CSimpleStringA strDestFile = strDestPath + "\\" + strFindName;
-				if (ExistsFileA(strSourceFile))
-				{	
-					// 先去除目标文件只读属性
-					if (ExistsFileA(strDestFile))
-						RemoveFileReadOnlyAttributeA(strDestFile);
-
-					LOG_TRACE("copy file from [%s] to [%s]", (const char*)strSourceFile, (const char*)strDestFile);
-					BOOL bRet = CopyFileA(strSourceFile, strDestFile, FALSE);
-
-					// 去除只读属性
-					if (bRet)
-						RemoveFileReadOnlyAttributeA(strDestFile);				
-					else
-					{
-						// 覆盖失败,则生成.new副本
-						DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("copy file [%s] to [%s] fail, now save as .new file",  (const char*) strSourcePath, (const char*) strDestFile);
-
-						strDestFile += ".new";
-						bRet = CopyFileA(strSourceFile, strDestFile, FALSE);
-						if (bRet)
-						{
-							RemoveFileReadOnlyAttributeA(strDestPath);				
-							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("copy [%s] as [%s] succeed", (const char*)strSourceFile, (const char*) strDestFile);
-						}
-						else
-						{
-							LogError(Severity_Low, Error_Unexpect, 0, CSimpleStringA::Format("copy file [%s] as [%s] fail",  (const char*) strSourceFile, (const char*) strDestFile));
-							return Error_Block;
-						}
-					}
-				}
-				else
-				{
-					LogError(Severity_Low, Error_NotExist, 0, CSimpleStringA::Format("file [%s] to copy not exists", (const char*)strSourceFile));
-					return Error_NotExist;
-				}
-			}
-		}
-	} while (_findnext(Handle, &FileInfo) == 0);
-
-	_findclose(Handle);
-	return Error_Succeed;
-
-#else
-	if (CopyDirA(strSourcePath, strDestPath)) {
-		return Error_Succeed;
-	}
-	return Error_Unexpect;
-
-#endif //_WIN32
-
-
-}
-
-CSimpleStringA GetFileDirectory(const char *pszFullPath)
-{
-	int i=strlen(pszFullPath)-1;
-	for( ; i>0 && pszFullPath[i]!=SPLIT_SLASH; i--)NULL;
-	return CSimpleStringA(pszFullPath, i);
-}
-
-#ifdef _WIN32
-
-bool SpEntityPrivilege::IsWow64Process()
-{
-	typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
-	LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
-	
-	BOOL bIsWow64 = FALSE;
-	if (NULL != fnIsWow64Process)
-	{
-		if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("call IsWow64Process error: %d", GetLastError());
-			return false;
-		}
-
-		return bIsWow64 == TRUE;
-	}
-	else
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("get IsWow64Process error: %d", GetLastError());
-		return false;
-	}
-}
-#endif //_WIN32
-
-// result=0&msg=install ok
-bool SpEntityPrivilege::GetSysUpgradeResult(const char *pszResultLog, ErrorCodeEnum &eErrorCode, CSimpleStringA &strErrMsg)
-{
-	// 设置初始值
-	eErrorCode = Error_Succeed;
-	strErrMsg = "";
-
-	if (!ExistsFileA(pszResultLog))
-	{
-		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)(CSimpleStringA::Format("result log [%s] not exist", pszResultLog));
-		strErrMsg = "result.log not exist";
-		return false;
-	}
-
-	FILE *pResultLog = fopen(pszResultLog, "r");
-	if (pResultLog == NULL)
-	{
-		LogError(Severity_Low, Error_Unexpect, 0, CSimpleStringA::Format("open result log [%s] fail", pszResultLog));
-		strErrMsg = "open result.log fail";
-		return false;
-	}
-
-	char szTmp[4096] = {};
-	int nRead = fread_s(szTmp, sizeof(szTmp), 1, sizeof(szTmp), pResultLog);
-	CSimpleStringA strResult = szTmp;
-	fclose(pResultLog);
-	pResultLog = NULL;
-
-	auto arr = strResult.Split('&');
-	for (int i = 0; i < arr.GetCount(); i++)
-	{
-		auto arr2 = arr[i].Split('=');
-		if (arr2.GetCount() == 2)
-		{
-			if (stricmp(arr2[0], "result") == 0)
-				eErrorCode = (ErrorCodeEnum)(DWORD)atoi(arr2[1]);
-			else if (stricmp(arr2[0], "msg") == 0)
-				strErrMsg = arr2[1];
-		}
-	}
-
-	return true;
-}
-
-// File*A.*
-bool SpEntityPrivilege::IsFileMatch(const char *pszFilter, const char *pszFileName)
-{
-	if (stricmp(pszFilter, "*") == 0 || stricmp(pszFilter, "*.*") == 0)
-		return true;
-
-	const char *p1 = pszFilter;
-	const char *p2 = pszFileName;
-
-	if (p1 == NULL)
-		return true;
-
-	if (p2 == NULL)
-		return false;
-
-	if (*p1 ==NULL && *p2 ==NULL)
-		return true;
-	else if (*p1 == NULL)
-		return false;
-	else if (*p2 == NULL)
-	{
-		// 查找*p1是否全是*
-		while(*p1 == '*') 
-			p1++;
-
-		if (*p1 == NULL)
-			return true;
-		else
-			return false;
-	}
-
-	if (*p1 != '*')
-	{
-		if (tolower(*p1) != tolower(*p2))
-			return false;
-		else
-			return IsFileMatch(p1+1, p2+1);
-	}
-	else
-	{
-		while(*++p1 == '*');
-
-		if (*p1 == NULL)
-			return true;
-
-		while (*p2)
-		{
-			while(tolower(*p1) != tolower(*p2) && *++p2);
-
-			if (*p2  == NULL)
-				return false;
-
-			if(IsFileMatch(p1+1, p2+1))
-				return true;
-
-			p2++;
-		}
-
-		return false;
-	}
-}
-
-CSimpleStringA SpEntityPrivilege::GetFileDirectory(const char *pszFullPath)
-{
-	int i=strlen(pszFullPath);
-	for( ; i>0 && pszFullPath[i-1]!=SPLIT_SLASH; i--)NULL;
-	return CSimpleStringA(pszFullPath, i);
-}
-
 ErrorCodeEnum SpEntityPrivilege::SetSysDebugLevel(const char *pszEntityName,DebugLevelEnum eDebugLevel,bool bPersist)
 {
 	sp_env_t *env = sp_get_env();

+ 1 - 8
Framework/spbase/SpEntityPrivilege.h

@@ -58,7 +58,7 @@ public:
 		unsigned long* t_upload_TerminalSys_Err, unsigned long* t_upload_TerminalUser_Err,
 		unsigned long* t_upload_BussinessSys_Err, unsigned long* t_upload_BussinessUser_Err, unsigned long* t_upload_beidou_Err);
 
-	//先调用这个去初始化url
+	//鍏堣皟鐢ㄨ繖涓�幓鍒濆�鍖杣rl
 	virtual ErrorCodeEnum InitCfgUrl(VTMInitParam& info);
 	virtual ErrorCodeEnum TryUpdateCfg();
 	virtual ErrorCodeEnum TryUpdateCenterCfg(bool& isUpdate, bool& isReset, CSimpleString& version);
@@ -94,13 +94,6 @@ private:
 	static void __on_entity_state(sp_mod_entity_state_listener_t *listener, int entity_id, int trigger_entity_id, int last_state, int curr_state, void *user_data);
 	static void __on_create_connection(sp_mod_entity_state_listener_t *listener, int src_entity_id, int dst_entity_id, void *user_data);
 	static void __on_close_connection(sp_mod_entity_state_listener_t *listener, int src_entity_id, int dst_entity_id, void *user_data);
-
-	bool IsFileMatch(const char *pszFilter, const char *pszFileName);
-	CSimpleStringA GetFileDirectory(const char *pszFullPath);
-	bool IsWow64Process();
-	bool GetSysUpgradeResult(const char *pszResultLog, ErrorCodeEnum &eErrorCode, CSimpleStringA &strErrMsg);
-	bool RecursiveCopyDir(const char* pszSourceDir, const char* pszDestDir, CSimpleStringA& strErrInfo);
-
 	ErrorCodeEnum UpdateVerTxt(const char* strActiveFilePath, const char* toWriteVersionStr, bool toCheck = false);
 
 

+ 1 - 2
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -1901,8 +1901,7 @@ static int Is32R64Platform()
     typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
     if (isWow64 == -1) {
         BOOL bIsWow64 = FALSE;
-        LPFN_ISWOW64PROCESS fnIsWow64Process =
-            (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
+        LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
         if (NULL != fnIsWow64Process) {
             if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
                 DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("detect is running with 64bit or not failed: %u", GetLastError());

+ 1 - 1
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -2393,7 +2393,7 @@ void ResourceWatcherEntity::InstallSogou(SpReqAnsContext<ResourceWatcherService_
 
                             auto arr = tInstallRe.Split('&');
                             if (arr.GetCount() != 2) {
-                                DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetSysUpgradeResult")("GetSysUpgradeResult read result log format fail");
+                                DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("read result log format fail");
                                 tmpMsg = "read result.log format fail,eg result=0&msg=install ok";
                             }
                             for (int i = 0; i < arr.GetCount(); i++) {