Преглед изворни кода

Z991240-991 #comment bugfix:解决分割符问题

胡琛80272472 пре 4 година
родитељ
комит
cd4e886816

+ 32 - 27
Module/mod_SalesRecorder/mod_SalesRecorder.cpp

@@ -156,9 +156,10 @@ static BOOL FindMatchedFile(LPCSTR sFindPath, LPCSTR sFindFileName, ULONGLONG &u
 	BOOL fFinished = FALSE;
 
 	strcpy(sFormatFileName, sFindPath);
-	if(sFindPath[strlen(sFindPath)-1] != '\\')
-	{
-		strcat(sFormatFileName, "\\*");
+	if(sFindPath[strlen(sFindPath)-1] != SPLIT_SLASH)
+	{	
+		strcat(sFormatFileName, SPLIT_SLASH_STR);
+		strcat(sFormatFileName, "*");
 	}
 	else
 	{
@@ -178,9 +179,9 @@ static BOOL FindMatchedFile(LPCSTR sFindPath, LPCSTR sFindFileName, ULONGLONG &u
 		while (!fFinished)
 		{
 			strcpy(sPath, sFindPath);
-			if(sPath[strlen(sPath)-1] != '\\')
+			if(sPath[strlen(sPath)-1] != SPLIT_SLASH)
 			{
-				strcat(sPath, "\\");
+				strcat(sPath, SPLIT_SLASH_STR);
 			}
 			strcat(sPath, FindFileData.cFileName);
 
@@ -484,15 +485,15 @@ ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
 	if (Error != Error_Succeed) {
 		LOG_TRACE("get global record temp path failed!");
 	}
-	if (m_TempDir.GetLength() > 0 && m_TempDir[m_TempDir.GetLength()-1] != '\\') {
-		m_TempDir += "\\";
+	if (m_TempDir.GetLength() > 0 && m_TempDir[m_TempDir.GetLength()-1] != SPLIT_SLASH) {
+		m_TempDir += SPLIT_SLASH_STR;
 	}
 	Error = GetFunction()->GetPath("UploadVideo", m_RecordSaveDir);
 	if (Error != Error_Succeed) {
 		LOG_TRACE("get global record save path failed!");
 	}
-	if (m_RecordSaveDir.GetLength() > 0 && m_RecordSaveDir[m_RecordSaveDir.GetLength()-1] != '\\') {
-		m_RecordSaveDir += "\\";
+	if (m_RecordSaveDir.GetLength() > 0 && m_RecordSaveDir[m_RecordSaveDir.GetLength()-1] != SPLIT_SLASH) {
+		m_RecordSaveDir += SPLIT_SLASH_STR;
 	}
 
 	return Error;
@@ -618,7 +619,11 @@ void CSalesRecorderEntity::OnTimeout( DWORD dwTimerID )
 		if (strstr(m_SalesVideoName, "OFL")) {
 			Dbg("On DISKCHK timer!");
 			int nFreeRatio = 0;
+#ifdef RVC_OS_WIN
 			m_last_disk_overtop = !CheckDiskStatus("C:\\",m_max_disk_percent,&nFreeRatio);
+#else
+			m_last_disk_overtop = !CheckDiskStatus("/home/", m_max_disk_percent, &nFreeRatio);
+#endif
 			if (m_last_disk_overtop) {
 				CSimpleStringA msg = CSimpleStringA::Format("磁盘所剩空间不足%d%%,已停止离线双录!",100-m_max_disk_percent);
 				Dbg((LPCTSTR)msg);
@@ -999,8 +1004,8 @@ ErrorCodeEnum CSalesRecorderEntity::ShowVideo( const char *wmvfilename )
 		CSimpleStringA strPath;
 		ErrorCodeEnum Error = GetFunction()->GetPath("Temp", strPath);
 		if (Error == Error_Succeed) {
-			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != '\\') {
-				strPath += "\\";
+			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != SPLIT_SLASH) {
+				strPath += SPLIT_SLASH_STR;
 			}
 			CSimpleStringA strFindFileName = CSimpleStringA::Format("%s*.wmv", wmvfilename);
 			ULONGLONG uVideoCount = 0;
@@ -1033,8 +1038,8 @@ ErrorCodeEnum CSalesRecorderEntity::PlaySalesRecordVideo( const char *wmvfilenam
 		CSimpleStringA strPath;
 		ErrorCodeEnum Error = GetFunction()->GetPath("Temp", strPath);
 		if (Error == Error_Succeed) {
-			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != '\\') {
-				strPath += "\\";
+			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != SPLIT_SLASH) {
+				strPath += SPLIT_SLASH_STR;
 			}
 			CSimpleStringA strFindFileName = CSimpleStringA::Format("%s*.wmv", wmvfilename);
 			ULONGLONG uVideoCount = 0;
@@ -1065,8 +1070,8 @@ void CSalesRecorderEntity::DeleteAllVideo( const char *wmvfilename )
 		CSimpleStringA strPath;
 		ErrorCodeEnum Error = GetFunction()->GetPath("Temp", strPath);
 		if (Error == Error_Succeed) {
-			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != '\\') {
-				strPath += "\\";
+			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != SPLIT_SLASH) {
+				strPath += SPLIT_SLASH_STR;
 			}
 			ULONGLONG uVideoCount = 0;
 			// 删除客户经理录像 edit by ly 2018/03/05
@@ -1140,8 +1145,8 @@ void CSalesRecorderEntity::DeleteVideo( const char *wmvfilename )
 		CSimpleStringA strPath;
 		ErrorCodeEnum Error = GetFunction()->GetPath("Temp", strPath);
 		if (Error == Error_Succeed) {
-			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != '\\') {
-				strPath += "\\";
+			if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != SPLIT_SLASH) {
+				strPath += SPLIT_SLASH_STR;
 			}
 			CSimpleStringA strFindFileName = CSimpleStringA::Format("%s*.wmv", wmvfilename);
 			ULONGLONG uVideoCount = 0;
@@ -1191,8 +1196,8 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char *wmvfilename )
 		ErrorCodeEnum Error = GetFunction()->GetPath("Temp", sourPath);
 		if(Error == Error_Succeed)
 		{
-			if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength()-1] != '\\') {
-				sourPath += "\\";
+			if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength()-1] != SPLIT_SLASH) {
+				sourPath += SPLIT_SLASH_STR;
 			}
 			ULONGLONG uVideoCount = 0;
 			// 移动销售录像 edit by ly 2018/03/05
@@ -1209,8 +1214,8 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char *wmvfilename )
 				Error = GetFunction()->GetPath("UploadVideo", destPath);
 				if(Error == Error_Succeed)
 				{
-					if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != '\\') {
-						destPath += "\\";
+					if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != SPLIT_SLASH) {
+						destPath += SPLIT_SLASH_STR;
 					}
 					CSimpleStringA sourFileName, destFileName;
 					BOOL bMoveSucc = TRUE;
@@ -1248,8 +1253,8 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char *wmvfilename )
 				Error = GetFunction()->GetPath("UploadVideo", destPath);
 				if(Error == Error_Succeed)
 				{
-					if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != '\\') {
-						destPath += "\\";
+					if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != SPLIT_SLASH) {
+						destPath += SPLIT_SLASH_STR;
 					}
 					CSimpleStringA sourFileName, destFileName;
 					BOOL bMoveSucc = TRUE;
@@ -2323,12 +2328,12 @@ void CSalesRecorderEntity::UploadTempPathVideos()
 	ErrorCodeEnum Error = GetFunction()->GetPath("Temp", sourPath);
 	Error = GetFunction()->GetPath("UploadVideo", destPath);
 	
-	if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength()-1] != '\\') {
-		sourPath += "\\";
+	if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength()-1] != SPLIT_SLASH) {
+		sourPath += SPLIT_SLASH_STR;
 	}
 
-	if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != '\\') {
-		destPath += "\\";
+	if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != SPLIT_SLASH) {
+		destPath += SPLIT_SLASH_STR;
 	}
 
 	if(Error == Error_Succeed)

+ 4 - 4
Module/mod_recorder/mod_recorder.cpp

@@ -142,15 +142,15 @@ public:
 		if (Error != Error_Succeed) {
 			LOG_TRACE("get global record temp path failed!");
 		}
-		if (m_TempDir.GetLength() > 0 && m_TempDir[m_TempDir.GetLength()-1] != '\\') {
-			m_TempDir += "\\";
+		if (m_TempDir.GetLength() > 0 && m_TempDir[m_TempDir.GetLength()-1] != SPLIT_SLASH) {
+			m_TempDir += SPLIT_SLASH_STR;
 		}
 		Error = GetFunction()->GetPath("UploadVideo", m_RecordSaveDir);
 		if (Error != Error_Succeed) {
 			LOG_TRACE("get global record save path failed!");
 		}
-		if (m_RecordSaveDir.GetLength() > 0 && m_RecordSaveDir[m_RecordSaveDir.GetLength()-1] != '\\') {
-			m_RecordSaveDir += "\\";
+		if (m_RecordSaveDir.GetLength() > 0 && m_RecordSaveDir[m_RecordSaveDir.GetLength()-1] != SPLIT_SLASH) {
+			m_RecordSaveDir += SPLIT_SLASH_STR;
 		}
 
 		return Error;

+ 1 - 1
Module/mod_screenshot/mod_screenshot.cpp

@@ -231,7 +231,7 @@ public:
 	{
 		char tmp[MAX_PATH];
 		static int seq = 0;
-		sprintf(tmp, ".\\capture_%08d.dat", seq++);
+		sprintf(tmp, ".%scapture_%08d.dat", SPLIT_SLASH_STR, seq++);
 		FILE *fp = fopen(tmp, "wb");
 		if (fp) 
 		{

+ 35 - 1
Other/libfacecapture/libfacecapture.cpp

@@ -18,6 +18,40 @@
 #include "libvideoqueue.h"
 //#include "libsharememory.h"
 
+#define SLASH '/'
+#define BACK_SLASH '\\'
+
+#define MB_SLASH_STR "/"
+#define MB_BACK_SLASH_STR "\\"
+
+#define W_SLASH_STR L"/"
+#define W_BACK_SLASH_STR L"\\"
+
+#if defined(UNICODE) || defined(_UNICODE)
+#define SLASH_STR W_SLASH_STR
+#define BACK_SLASH_STR W_BACK_SLASH_STR
+#else 
+#define SLASH_STR MB_SLASH_STR
+#define BACK_SLASH_STR MB_BACK_SLASH_STR
+#endif
+
+#ifdef _WIN32
+#define SPLIT_SLASH BACK_SLASH
+#define SPLIT_SLASH_STR BACK_SLASH_STR
+#define MB_SPLIT_SLASH_STR MB_BACK_SLASH_STR
+#define W_SPLIT_SLASH_STR   W_BACK_SLASH_STR
+
+#define LINE_BREAK_STR "\r\n"
+
+#else
+#define SPLIT_SLASH SLASH
+#define SPLIT_SLASH_STR SLASH_STR
+#define MB_SPLIT_SLASH_STR MB_SLASH_STR
+#define W_SPLIT_SLASH_STR   W_SLASH_STR
+
+#define LINE_BREAK_STR "\n"
+
+#endif
 
 //#define SHAREMEM
 #ifdef RVC_OS_WIN
@@ -380,7 +414,7 @@ private:
 	void FIGetDir(const char*CascadeType,const char *base_dir,char*dir)
 	{
 		strcpy(dir, m_stFaceConfig.strFaceDataDirPath);
-		strcat(dir,"\\");
+		strcat(dir, SPLIT_SLASH_STR);
 		strcat(dir,CascadeType);
 	}
 	//дÈËÁ³¼ì²âÊý¾Ý

+ 38 - 2
Other/libwmvrecord/libwmvrecord.cpp

@@ -37,6 +37,41 @@
 #include "iaudionsinterface.h"
 #include "libaudiotransqueue.h"
 
+#define SLASH '/'
+#define BACK_SLASH '\\'
+
+#define MB_SLASH_STR "/"
+#define MB_BACK_SLASH_STR "\\"
+
+#define W_SLASH_STR L"/"
+#define W_BACK_SLASH_STR L"\\"
+
+#if defined(UNICODE) || defined(_UNICODE)
+#define SLASH_STR W_SLASH_STR
+#define BACK_SLASH_STR W_BACK_SLASH_STR
+#else 
+#define SLASH_STR MB_SLASH_STR
+#define BACK_SLASH_STR MB_BACK_SLASH_STR
+#endif
+
+#ifdef _WIN32
+#define SPLIT_SLASH BACK_SLASH
+#define SPLIT_SLASH_STR BACK_SLASH_STR
+#define MB_SPLIT_SLASH_STR MB_BACK_SLASH_STR
+#define W_SPLIT_SLASH_STR   W_BACK_SLASH_STR
+
+#define LINE_BREAK_STR "\r\n"
+
+#else
+#define SPLIT_SLASH SLASH
+#define SPLIT_SLASH_STR SLASH_STR
+#define MB_SPLIT_SLASH_STR MB_SLASH_STR
+#define W_SPLIT_SLASH_STR   W_SLASH_STR
+
+#define LINE_BREAK_STR "\n"
+
+#endif
+
 
 #ifndef CAPTURE_CLOCK
 #define CAPTURE_CLOCK		8000
@@ -1656,9 +1691,10 @@ private:
 		HANDLE hFind;
 
 		strcpy(sFormatFileName, sFindPath);
-		if(sFindPath[strlen(sFindPath)-1] != '\\')
+		if(sFindPath[strlen(sFindPath)-1] != SPLIT_SLASH)
 		{
-			strcat(sFormatFileName, "\\*");
+			strcat(sFormatFileName, SPLIT_SLASH_STR);
+			strcat(sFormatFileName, "*");
 		}
 		else
 		{