|
@@ -969,15 +969,15 @@ int CRecorderEntity::GetRecordVideoInfo(const char* videofilename, char* strSess
|
|
|
int CRecorderEntity::SaveExceptionRecordVideos()
|
|
|
{
|
|
|
int iRet = -1;
|
|
|
+
|
|
|
#ifdef RVC_OS_WIN
|
|
|
- char srcFilePath[MAX_PATH]={0};
|
|
|
WIN32_FIND_DATA FindFileData;
|
|
|
HANDLE hFind;
|
|
|
bool fFinished = false;
|
|
|
char strVideoFormat[MAX_PATH] = { 0 };
|
|
|
- snprintf(strVideoFormat, MAX_PATH, "%s", RECORD_MP4_SUFFIX);
|
|
|
-
|
|
|
- snprintf(srcFilePath, MAX_PATH, "%s*.%s", m_TempDir.GetData(), strVideoFormat);
|
|
|
+ char srcFilePath[MAX_PATH] = { 0 };
|
|
|
+ _snprintf(strVideoFormat, MAX_PATH, "%s", RECORD_MP4_SUFFIX);
|
|
|
+ _snprintf(srcFilePath, MAX_PATH, "%s*.%s", m_TempDir.GetData(), strVideoFormat);
|
|
|
|
|
|
hFind = FindFirstFile(srcFilePath, &FindFileData);
|
|
|
|
|
@@ -1002,6 +1002,11 @@ int CRecorderEntity::SaveExceptionRecordVideos()
|
|
|
filecryption_callback_t cb = {0};
|
|
|
cb.dbg = &rvcDbg;
|
|
|
if (false == is_file_encrypted(srcfile.GetData(), &cb)){
|
|
|
+ if (strstr(FindFileData.cFileName, RVC_FILEENC_STR)) {
|
|
|
+ RvcDeleteFile(srcfile.GetData());
|
|
|
+ goto on_next;
|
|
|
+ }
|
|
|
+
|
|
|
if (is_file_completed(srcfile.GetData(), &cb)) {
|
|
|
HandleEncryptVideoRecord(srcfile.GetData());
|
|
|
}
|
|
@@ -1010,20 +1015,28 @@ int CRecorderEntity::SaveExceptionRecordVideos()
|
|
|
char* pIndex = NULL;
|
|
|
if (pIndex = strstr(FindFileData.cFileName, RVC_FILEENC_STR)){
|
|
|
char strname[MAX_PATH] = {0};
|
|
|
- memcpy(strname, pIndex+strlen(RVC_FILEENC_STR), strlen(pIndex+strlen(RVC_FILEENC_STR)));
|
|
|
- CSimpleStringA tempsrcfile = CSimpleStringA::Format("%s%s",m_TempDir.GetData(), strname);
|
|
|
- if (!rename(srcfile.GetData(),tempsrcfile.GetData())){
|
|
|
+ memcpy(strname, pIndex + strlen(RVC_FILEENC_STR), strlen(pIndex+strlen(RVC_FILEENC_STR)));
|
|
|
+ CSimpleStringA tempsrcfile = CSimpleStringA::Format("%s%s", m_TempDir.GetData(), strname);
|
|
|
+ if (rvcMoveFile(srcfile.GetData(),tempsrcfile.GetData())){
|
|
|
srcfile = tempsrcfile;
|
|
|
memset(FindFileData.cFileName, 0, MAX_PATH);
|
|
|
memcpy(FindFileData.cFileName, strname, strlen(strname));
|
|
|
}
|
|
|
else{
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), srcfile.GetData()).GetData());
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s, delete it.", GetLastError(), srcfile.GetData()).GetData());
|
|
|
+ RvcDeleteFile(srcfile.GetData());
|
|
|
+ goto on_next;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (strstr(srcfile.GetData(), RVC_FILEENC_STR)) {
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_ABNORMAL_RECORD_FILE, CSimpleStringA::Format("abnormal file %s, delete it.", srcfile.GetData()).GetData());
|
|
|
+ RvcDeleteFile(srcfile.GetData());
|
|
|
+ goto on_next;
|
|
|
+ }
|
|
|
+
|
|
|
CSimpleStringA dstfile = CSimpleStringA::Format("%s%s",m_RecordSaveDir.GetData(), FindFileData.cFileName);
|
|
|
bool bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if(!bRet) {
|
|
@@ -1070,6 +1083,11 @@ on_next:
|
|
|
filecryption_callback_t cb = { 0 };
|
|
|
cb.dbg = &rvcDbg;
|
|
|
if (false == is_file_encrypted(srcfile.GetData(), &cb)) {
|
|
|
+ if (strstr(ptr->d_name, RVC_FILEENC_STR)) {
|
|
|
+ RvcDeleteFile(srcfile.GetData());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
if (is_file_completed(srcfile.GetData(), &cb)) {
|
|
|
HandleEncryptVideoRecord(srcfile.GetData());
|
|
|
}
|
|
@@ -1087,11 +1105,19 @@ on_next:
|
|
|
}
|
|
|
else {
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("%s(%d) while rename %s.", strerror(errno), errno, srcfile.GetData()).GetData());
|
|
|
+ RvcDeleteFile(srcfile.GetData());
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (strstr(srcfile.GetData(), RVC_FILEENC_STR)) {
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_ABNORMAL_RECORD_FILE, CSimpleStringA::Format("abnormal file %s, delete it.", srcfile.GetData()).GetData());
|
|
|
+ RvcDeleteFile(srcfile.GetData());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
CSimpleStringA dstfile = CSimpleStringA::Format("%s%s", m_RecordSaveDir.GetData(), ptr->d_name);
|
|
|
bool bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if (!bRet) {
|