Ver Fonte

Z991239-6390 #comment 路径分隔符处理

80374374 há 2 meses atrás
pai
commit
96381cfe8d

+ 1 - 1
Framework/Common/SpBase.h

@@ -1693,7 +1693,7 @@ SPBASE_API void LogTrace(const char* pszMessage, const char* pszSourceFile, cons
 
 
 SPBASE_API CSimpleStringA GetSysErrMsg(DWORD nErrCode);
-SPBASE_API const char *_GetFileName(const char *pszFilePath);
+extern "C" SPBASE_API const char *_GetFileName(const char *pszFilePath);
 
 /*
 基于当前mod中包含有restful模块,需要把数据从framework中传递到librestful,会比较困难

+ 1 - 1
Framework/spbase/SpBase.cpp

@@ -756,7 +756,7 @@ SPBASE_API CSimpleStringA GetSysErrMsg(DWORD nErrCode)
 #endif //RVC_OS_WIN
 }
 
-SPBASE_API const char *_GetFileName(const char *pszFilePath)
+extern "C" SPBASE_API const char *_GetFileName(const char *pszFilePath)
 {
 	int i=strlen(pszFilePath);
 	for( ; i>0 && pszFilePath[i-1]!=SPLIT_SLASH; i--)NULL;

+ 0 - 7
Framework/spbase/sp_bcm.c

@@ -281,13 +281,6 @@ static void daemon_unlock(sp_bcm_daemon_t *daemon)
 	LeaveCriticalSection(&daemon->lock);
 }
 
-static const char *_GetFileName(const char *pszFilePath)
-{
-	int i=strlen(pszFilePath);
-	for( ; i>0 && pszFilePath[i-1]!='\\'; i--)NULL;
-	return pszFilePath+i;
-}
-
 static int daemon_on_pkt(sp_svc_t *svc,int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt, void *user_data)
 {
 	sp_bcm_daemon_t *daemon = (sp_bcm_daemon_t *)user_data;

+ 1 - 6
Framework/spbase/sp_btr.c

@@ -409,12 +409,7 @@ sp_btr_reocrd_t* sp_btr_get_rec_before(const char *bootrec_path, sp_btr_context_
 	y2k_to_localtime(before_this_time, &st);
 	while (nTryCount++ <= 12)
 	{
-		#ifdef _WIN32
-		sprintf(szBootLog, "%s\\%04d%02d.log", bootrec_path, st.wYear, st.wMonth);
-        #else
-		sprintf(szBootLog, "%s/%04d%02d.log", bootrec_path, st.wYear, st.wMonth);
-		#endif
-
+		sprintf(szBootLog, "%s" SPLIT_SLASH_STR "%04d%02d.log", bootrec_path, st.wYear, st.wMonth);
 		if (!ExistsFileA(szBootLog))
 		{
 			DbgWithLinkForC(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM,"boot log %s not exists", szBootLog);

+ 1 - 0
Framework/spbase/sp_mod.c

@@ -872,6 +872,7 @@ static int create_module_process(const char *mod_name, int epid, int range, int
 		return -1;
 	}
 
+	//TODO: CrossPlaform  [Gifur@2025729]
 	if (runType == 1)
 		sprintf(app, ".\\bin\\sphost.exe {%s} %d", mutexName, shellId);
 	else

+ 7 - 23
Framework/spbase/sp_pst.c

@@ -29,28 +29,17 @@ struct sp_pst_elem_t {
 
 static const char *get_full_path(const char *base_dir, const char *ent, const char *cls, const char *obj, char *buf)
 {
-#ifdef _WIN32
 	if (cls) {
 		if (obj) {
-			sprintf(buf, "%s\\objects\\%s\\%s\\%s.dat", base_dir, ent, cls, obj);
-		} else {
-			sprintf(buf, "%s\\objects\\%s\\%s", base_dir, ent, cls);
+			sprintf(buf, "%s" SPLIT_SLASH_STR "objects" SPLIT_SLASH_STR "%s" SPLIT_SLASH_STR "%s" SPLIT_SLASH_STR "%s.dat", base_dir, ent, cls, obj);
 		}
-	} else {
-		sprintf(buf, "%s\\objects\\%s", base_dir, ent);
-	}
-#else
-	if (cls) {
-		if (obj) {
-			sprintf(buf, "%s/objects/%s/%s/%s.dat", base_dir, ent, cls, obj);
-		} else {
-			sprintf(buf, "%s/objects/%s/%s", base_dir, ent, cls);
+		else {
+			sprintf(buf, "%s" SPLIT_SLASH_STR "objects" SPLIT_SLASH_STR "%s" SPLIT_SLASH_STR "%s", base_dir, ent, cls);
 		}
-	} else {
-		sprintf(buf, "%s/objects/%s", base_dir, ent);
 	}
-#endif
-	
+	else {
+		sprintf(buf, "%s" SPLIT_SLASH_STR "objects" SPLIT_SLASH_STR "%s", base_dir, ent);
+	}
 	return buf;
 }
 
@@ -517,12 +506,7 @@ static void recover_persist_dir_files(const char *dir)
 	WIN32_FIND_DATAA fd;
 
 	strcpy(szFile, dir);
-	#ifdef _WIN32
-	strcat(szFile, "\\*");
-    #else
-	strcat(szFile, "/*");
-	#endif
-
+	strcat(szFile, SPLIT_SLASH_STR "*");
 	hFind = FindFirstFileA(szFile, &fd);
 	if (hFind != INVALID_HANDLE_VALUE) {
 		do {

+ 1 - 7
Framework/spbase/sp_sps.c

@@ -57,6 +57,7 @@ static void __on_accept(SOCKET policy_fd)
 	DbgWithLinkForC(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM, "accept from %s:%d", inet_ntoa(from_addr.sin_addr), ntohs(from_addr.sin_port));
 
 	WSAEventSelect(conn_fd, NULL, 0);
+	//TODO: CrossPlaform  [Gifur@2025729]
 #ifdef _WIN32
 	ioctlsocket(conn_fd, FIONBIO, &iMode);
 #else
@@ -97,13 +98,6 @@ on_error:
 	closesocket(conn_fd);
 }
 
-static const char *_GetFileName(const char *pszFilePath)
-{
-	int i=strlen(pszFilePath);
-	for( ; i>0 && pszFilePath[i-1]!='\\'; i--)NULL;
-	return pszFilePath+i;
-}
-
 static unsigned int __stdcall __sps_worker_proc(void *arg)
 {
 	sp_sps_t *sps = (sp_sps_t*)arg;

+ 0 - 9
Framework/spbase/sp_tbs_unix.cpp

@@ -363,15 +363,6 @@ static const wchar_t *get_user_err_msg(int rc)
 	toolkit_mbs2wcs(msg, wmsg, 512);
 	return wmsg;
 }
-/*
-static const char *_GetFileName(const char *pszFilePath)
-{
-	int i=strlen(pszFilePath);
-	for( ; i>0 && pszFilePath[i-1]!='\\'; i--)NULL;
-	return pszFilePath+i;
-}
-*/
-
 
 static int create_connection(sp_tbs_t *tbs)
 {

+ 5 - 3
Framework/spshell/app.cpp

@@ -79,11 +79,13 @@ static void sig_handle(int signo)
 static int get_child_range()
 {
 	char tmp[32];
+	return _spawnl(_P_WAIT, 
 #ifdef RVC_OS_WIN
-	return _spawnl(_P_WAIT, ".\\bin\\sphost.exe", "sphost.exe", _itoa(sp_shm_get_range(0xffffffff), tmp, 10), NULL);
+		".\\bin\\sphost.exe", "sphost.exe",
 #else
-	return _spawnl(_P_WAIT, "./bin/sphost", "sphost", _itoa(sp_shm_get_range(0xffffffff), tmp, 10), NULL);
-#endif //RVC_OS_WIN
+		"./bin/sphost", "sphost",
+#endif
+		_itoa(sp_shm_get_range(0xffffffff), tmp, 10), NULL);
 }
 
 static void on_info(sp_rpc_server_t *server, int epid, int svc_id, int call_type, iobuffer_t **info_pkt, void *user_data)

+ 3 - 3
Framework/spshell/svc.cpp

@@ -170,7 +170,7 @@ static int KickoffSpRestartInner(int options)
 		char exepath[MAX_PATH] = "";
 		getExePath(exepath);
 
-		CSimpleStringA csRestart, csVerPath, csAll, csSep("\""), csBlank(" "), csScript("wscript.exe"), csReFlag("r");
+		CSimpleStringA csRestart, csVerPath, csAll, csBlank(" "), csReFlag("r");
 		csRestart = CSimpleStringA(exepath) + "\\sprestart.exe";
 
 		sp_env_t* env = sp_get_env();
@@ -184,11 +184,11 @@ static int KickoffSpRestartInner(int options)
 		LPTSTR szCmdline = _strdup(csAll);
 		if (!CreateProcess(NULL, szCmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
 		{
-			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CreateProcess failed (%d).\n", GetLastError());
+			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CreateProcess failed (%d).", GetLastError());
 			return -1;
 		}
 
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CreateProcess Success PID:%d.\n", pi.dwProcessId);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("CreateProcess Success PID:%d.", pi.dwProcessId);
 		DWORD dwErr = GetLastError();
 
 		// Close process and thread handles. 

+ 1 - 0
Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp

@@ -5057,6 +5057,7 @@ int CUpgradeTaskFSM::ExecDepRunCmd(CSimpleStringA& strErrMsg, CInstallStep* ins)
 		CSimpleStringA err = "";
 		int ret = system_on(sysPathStr, true, err);
 #ifdef RVC_OS_WIN
+		//TODO: CrossPlaform  [Gifur@2025729]
 		// 如果是Wow64模式,恢复System32重定向
 		if (bIsWow64)
 		{