|
@@ -12,6 +12,7 @@
|
|
|
#include "y2k_time.h"
|
|
|
#include <string.h>
|
|
|
#include "filecryption.h"
|
|
|
+#include "fileutil.h"
|
|
|
|
|
|
#include "mod_facetracking/sysvar.h"
|
|
|
#include "mod_interactivecontrol/Event.h"
|
|
@@ -44,34 +45,6 @@ using namespace Recorder;
|
|
|
#define RVC_MIN_RECORD_FILESIZE 1024
|
|
|
#endif
|
|
|
|
|
|
-//TODO: CrossPlaform 1111 [Gifur@2025730]
|
|
|
-static unsigned long GetFileSize(const char* pfilename)
|
|
|
-{
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- unsigned long usize = 0;
|
|
|
- if (NULL == pfilename) {
|
|
|
- return usize;
|
|
|
- }
|
|
|
-
|
|
|
- FILE* pFile = fopen(pfilename, "rb");
|
|
|
- if (pFile) {
|
|
|
- fseek(pFile, 0, SEEK_END);
|
|
|
- usize = ftell(pFile);
|
|
|
- fclose(pFile);
|
|
|
- }
|
|
|
-
|
|
|
- return usize;
|
|
|
-#else
|
|
|
- struct stat statbuf;
|
|
|
- if (0 == stat(pfilename, &statbuf)) {
|
|
|
- return statbuf.st_size;
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("errno info is %s.", strerror(errno));
|
|
|
- return 0;
|
|
|
- }
|
|
|
-#endif
|
|
|
-}
|
|
|
|
|
|
static const char* GetFileName(const char* pfilename)
|
|
|
{
|
|
@@ -84,7 +57,7 @@ static const char* GetFileName(const char* pfilename)
|
|
|
|
|
|
static void LogRecordFileInfo(const char* pszMessage)
|
|
|
{
|
|
|
- unsigned long ufilesize = GetFileSize(pszMessage);
|
|
|
+ unsigned long ufilesize = ReadFileSize(pszMessage);
|
|
|
|
|
|
char strhash[MAX_PATH] = { 0 };
|
|
|
get_file_sm3digest(strhash, MAX_PATH, pszMessage);
|
|
@@ -127,22 +100,6 @@ static bool rvcMoveFile(const char* strSrcFile, const char* strDstFile)
|
|
|
return bRet;
|
|
|
}
|
|
|
|
|
|
-//TODO: CrossPlaform [Gifur@2025728]
|
|
|
-static bool RvcDeleteFile(const char* strSrcFile)
|
|
|
-{
|
|
|
- bool bRet = false;
|
|
|
- if (NULL == strSrcFile) {
|
|
|
- return bRet;
|
|
|
- }
|
|
|
-
|
|
|
- if (0 == remove(strSrcFile)) {
|
|
|
- bRet = true;
|
|
|
- }
|
|
|
-
|
|
|
- return bRet;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
void RecordServiceSession::Handle_StartTransactionRecord(SpReqAnsContext<RecorderSerVice_StartTransactionRecord_Req, RecorderSerVice_StartTransactionRecord_Ans>::Pointer ctx)
|
|
|
{
|
|
|
DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
@@ -794,12 +751,8 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* videofilename)
|
|
|
LogRecordFileInfo(srcfile.GetData());
|
|
|
bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if(!bRet) {
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
-#else
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("%s(%d) while move %s ", strerror(errno), errno, srcfile.GetData()).GetData());
|
|
|
-#endif // RVC_OS_WIN
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED
|
|
|
+ , CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
else {
|
|
|
AddToVideoRecordList(dstfile.GetData());
|
|
@@ -811,12 +764,7 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* videofilename)
|
|
|
if (ExistsFile(srcfile.GetData())){
|
|
|
bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if(!bRet) {
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
-#else
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("%s(%d) while move %s ", strerror(errno), errno, srcfile.GetData()).GetData());
|
|
|
-#endif // RVC_OS_WIN
|
|
|
}
|
|
|
else {
|
|
|
AddToVideoRecordList(dstfile.GetData());
|
|
@@ -849,22 +797,16 @@ int CRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
|
|
|
if (0 != iresult){
|
|
|
LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_ENCRYPT_FAILED, CSimpleStringA::Format("encryption file %s failed, delete out temp file %s!", videofilename, strOutFile).GetData());
|
|
|
if (ExistsFile(strOutFile)) {
|
|
|
- if (!RvcDeleteFile(strOutFile)) {
|
|
|
+ if (!RemoveFileA(strOutFile)) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
|
|
|
}
|
|
|
}
|
|
|
return iRet;
|
|
|
}
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
- bool bRet = RvcDeleteFile(videofilename);
|
|
|
+ bool bRet = RemoveFileA(videofilename);
|
|
|
if(!bRet) {
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, CSimpleStringA::Format("Error Code %lu while delete %s, delete out temp file[%s]!", GetLastError(), videofilename, strOutFile).GetData());
|
|
|
-#else
|
|
|
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, CSimpleStringA::Format("%s(%d) while delete %s, delete out temp file[%s]!", strerror(errno), errno, videofilename, strOutFile).GetData());
|
|
|
-#endif // RVC_OS_WIN
|
|
|
- if (!RvcDeleteFile(strOutFile)){
|
|
|
+ if (!RemoveFileA(strOutFile)){
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
|
|
|
}
|
|
|
return iRet;
|
|
@@ -874,12 +816,8 @@ int CRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
|
|
|
iRet = 0;
|
|
|
}
|
|
|
else{
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
|
|
|
-#else
|
|
|
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("%s(%d) while rename %s.", strerror(errno), errno, strOutFile).GetData());
|
|
|
-#endif // RVC_OS_WIN
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED
|
|
|
+ , CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -921,12 +859,7 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* videofilename)
|
|
|
LogRecordFileInfo(srcfile.GetData());
|
|
|
bool bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if (!bRet) {
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()));
|
|
|
-#else
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("%s(%d) while move %s ", strerror(errno), errno, srcfile.GetData()));
|
|
|
-#endif // RVC_OS_WIN
|
|
|
}
|
|
|
else {
|
|
|
AddToVideoRecordList(dstfile.GetData());
|