From 77eee70b14d9d0b928befd9206be13b65b9841f8 Mon Sep 17 00:00:00 2001 From: payton Date: Thu, 11 Jan 2024 19:29:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E9=9B=86=E4=B8=AD=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/sf_app/code/include/sf_file.h | 1 + .../sf_app/code/source/fileMng/sf_file.c | 242 ++++++++++++++---- .../sf_app/code/source/storeMng/sf_storeMng.c | 23 +- 3 files changed, 212 insertions(+), 54 deletions(-) diff --git a/code/application/source/sf_app/code/include/sf_file.h b/code/application/source/sf_app/code/include/sf_file.h index 1655ced1d..54024a1a9 100755 --- a/code/application/source/sf_app/code/include/sf_file.h +++ b/code/application/source/sf_app/code/include/sf_file.h @@ -40,6 +40,7 @@ void sf_set_del_flag(BOOL flag); BOOL sf_get_del_flag(void); UINT32 sf_get_file_size(UINT8 * fname); UINT8 sf_get_send_file_list(char *sendfileList, UINT8 *fileTotal); +UINT8 sf_get_send_file_list_emmc(char *sendfileList, UINT8 *fileTotal); BOOL sf_check_auto_thumb_file(VOID); UINT8 sf_get_send_file_total(void); SINT32 sf_mem_upload_file_to_module(UINT32 MemPhotoAddr, UINT32 MemPhotosize); diff --git a/code/application/source/sf_app/code/source/fileMng/sf_file.c b/code/application/source/sf_app/code/source/fileMng/sf_file.c index 4895197b4..5f00919cb 100755 --- a/code/application/source/sf_app/code/source/fileMng/sf_file.c +++ b/code/application/source/sf_app/code/source/fileMng/sf_file.c @@ -1520,7 +1520,6 @@ BOOL sf_is_4g_module_usb_update_file_exist(UINT8 *updateFname) printf("no update file\n"); return FALSE; } - /************************************************* Function: sf_get_send_file_list Description: get send file list @@ -1543,20 +1542,134 @@ UINT8 sf_get_send_file_list(char *sendfileList, UINT8 *fileTotal) char *pFileHasSend = NULL; UINT32 fileOffset = 0; - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return FAIL; - } - if(0 == pPara->SendType){ - snprintf(sendListName, sizeof(sendListName), "%s%s", strg_path, SF_THUMB_SEND_AUTO); + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_SD_ROOT, SF_THUMB_SEND_AUTO); + if((access(sendListName, F_OK) != 0)) + { + return FAIL; + } }else { - snprintf(sendListName, sizeof(sendListName), "%s%s", strg_path, SF_THUMB_SEND_LIST); + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_SD_ROOT, SF_THUMB_SEND_LIST); + if((access(sendListName, F_OK) != 0)) + { + return FAIL; + } + } + sf_file_size_get(sendListName, &fsize); + fd = fopen(sendListName,"r"); + if(fd == 0) + { + printf("%s:%d [ERROR] %s open filed\n", __FUNCTION__, __LINE__, sendListName); + return FAIL; + } + else + { + if(pPara->SendMaxNum == 0) //unlimited + { + MaxFileNum = (sf_battery_value_get(0) >= 50 ? 200 : 100);// the last 100/200 files + } + else + { + MaxFileNum = pPara->SendMaxNum - pSifarPara->picSendMax; + } + printf("%s:%d Get %s MaxFileNum:%d\n", __FUNCTION__, __LINE__, sendListName, MaxFileNum); + + //fsize = sp5kFsFileSizeGet(fd); + if(fsize == 0) + { + fclose(fd); + sf_file_remove(sendListName); + return FAIL; + } + else if(fsize%SF_SEND_LIST_ITEM_LENGTH) //format error delete file list + { + //SLOGE((SINT8 *)"FTP ERROR: 303\n"); + printf("%s:%d FTP ERROR: 303\n", __FUNCTION__, __LINE__); + fclose(fd); + sf_file_remove(sendListName); + return FAIL; + } + else if(fsize > MaxFileNum*SF_SEND_LIST_ITEM_LENGTH) // the last 100/200 files + { + fseek(fd, fsize-MaxFileNum*SF_SEND_LIST_ITEM_LENGTH, SEEK_SET); + fsize = MaxFileNum*SF_SEND_LIST_ITEM_LENGTH; + } + *fileTotal = fsize/SF_SEND_LIST_ITEM_LENGTH; + printf("fileTotal=%d, fsize=%d\n", *fileTotal, fsize); + fread(sendfileList, fsize, 1, fd); + fclose(fd); + system("sync"); + oldFileKey = pPara->FileKey; + printf("last send key:%d\n", oldFileKey); + //oldFileKey = 1000003; //for debug + if((oldFileKey >= 1000001) && (oldFileKey <= 9999999)) //W1000001.JPG W9999999.JPG + { + snprintf(oldFileName, sizeof(oldFileName), "W%ld.JPG", oldFileKey); + printf("last send file:%s\n", oldFileName); + pFileHasSend = strstr(sendfileList, oldFileName); //MAX spend time <= 310ms + if(pFileHasSend != NULL) + { + pFileHasSend -= 1; + fileOffset = abs(pFileHasSend - sendfileList) + SF_SEND_LIST_ITEM_LENGTH; + fsize -= fileOffset; + printf("fileOffset=%d\n", fileOffset); + memmove(sendfileList, pFileHasSend + SF_SEND_LIST_ITEM_LENGTH, fsize); + *(sendfileList+fsize) = '\0'; + *fileTotal = fsize/SF_SEND_LIST_ITEM_LENGTH; + printf("fileTotal=%d, fsize=%d\n", *fileTotal, fsize); + } + } + + for(i=1; i <= *fileTotal; i++) // remove \r + { + *(sendfileList+i*SF_SEND_LIST_ITEM_LENGTH-2) = '\0'; + } + + //memdump(sendfileList, fsize); + //printf("get Success\n"); + return SUCCESS; + } +} + +/************************************************* + Function: sf_get_send_file_list_emmc + Description: get send file list emmc + Input: sendfname + Output: N/A + Return: N/A + Others: N/A +*************************************************/ +UINT8 sf_get_send_file_list_emmc(char *sendfileList, UINT8 *fileTotal) +{ + UIMenuStoreInfo *pPara = sf_app_ui_para_get(); + SF_PDT_PARAM_STATISTICS_S *pSifarPara = sf_statistics_param_get(); + char sendListName[64] = {0}; + FILE *fd = NULL; + UINT32 fsize = 0; + UINT8 i = 0; + UINT8 MaxFileNum = 200; + UINT32 oldFileKey = 0; + char oldFileName[SF_SEND_LIST_ITEM_LENGTH+1] = {0}; + char *pFileHasSend = NULL; + UINT32 fileOffset = 0; + + if(0 == pPara->SendType){ + + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_EMMC_ROOT, SF_THUMB_SEND_AUTO); + if((access(sendListName, F_OK) != 0)) + { + return FAIL; + } + } + else + { + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_EMMC_ROOT, SF_THUMB_SEND_LIST); + if((access(sendListName, F_OK) != 0)) + { + return FAIL; + } } sf_file_size_get(sendListName, &fsize); - free(strg_path); fd = fopen(sendListName,"r"); if(fd == 0) { @@ -1637,47 +1750,88 @@ BOOL sf_check_auto_thumb_file(VOID) BOOL ret = FALSE; UINT8 fileIndex = 0; - UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); - printf("%s:%d s\n", __FUNCTION__, __LINE__); - - char tmp[64] = {'\0'}; + char sendListName[64] = {0}; + UINT8 SDSendFalg = 0; + UINT8 EmmcSendFalg = 0; - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return FALSE; - } - + printf("%s:%d s\n", __FUNCTION__, __LINE__); + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); SF_SRCFILE_ATTR_S* fileCfg = sf_file_thumb_cfg_get(); if(0 == puiPara->SendType){ - snprintf(tmp, sizeof(tmp), "%s", SF_THUMB_SEND_AUTO); + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_EMMC_ROOT, SF_THUMB_SEND_AUTO); + if((access(sendListName, F_OK) == 0)) + { + EmmcSendFalg = 1; + } + + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_SD_ROOT, SF_THUMB_SEND_AUTO); + if((access(sendListName, F_OK) == 0)) + { + SDSendFalg = 1; + } }else { - snprintf(tmp, sizeof(tmp), "%s", SF_THUMB_SEND_LIST); + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_EMMC_ROOT, SF_THUMB_SEND_LIST); + if((access(sendListName, F_OK) == 0)) + { + EmmcSendFalg = 1; + } + + snprintf(sendListName, sizeof(sendListName), "%s%s", SF_SD_ROOT, SF_THUMB_SEND_LIST); + if((access(sendListName, F_OK) == 0)) + { + SDSendFalg = 1; + } } - if(SUCCESS == sf_get_send_file_list(&SendFileList[0][0], &SendFileTotal)){ - if (fileCfg) { - ret = TRUE; - fileCfg->filecnt = SendFileTotal; - for(fileIndex = 0; fileIndex < SendFileTotal; fileIndex++) - { - if((SF_CAM_MODE_PHOTO_VIDEO == (SendFileList[fileIndex][0] - '0')) || (SF_CAM_MODE_VIDEO2 == (SendFileList[fileIndex][0] - '0'))){ - fileCfg->stfileattr[fileIndex].enFileTye = SF_FILE_TYPE_PIC_VIDEO; - }else if(SF_CAM_MODE_PHOTO == (SendFileList[fileIndex][0] - '0')){ - fileCfg->stfileattr[fileIndex].enFileTye = SF_FILE_TYPE_PIC_SMALL; - } - snprintf(fileCfg->stfileattr[fileIndex].thumbfileName, sizeof(fileCfg->stfileattr[fileIndex].thumbfileName), "%s", &SendFileList[fileIndex][1]); - snprintf(fileCfg->stfileattr[fileIndex].thumbfilePath, sizeof(fileCfg->stfileattr[fileIndex].thumbfilePath), "%s%s%s", strg_path, SF_SEND_LIST_DIR, - &SendFileList[fileIndex][1]); - printf("%s:%d thumbfileSize:%d thumbfileName:%s thumbfilePath:%s\n", __FUNCTION__, __LINE__, - fileCfg->stfileattr[fileIndex].thumbfileSize,fileCfg->stfileattr[fileIndex].thumbfileName,fileCfg->stfileattr[fileIndex].thumbfilePath); - } - } - } + if(1 == SDSendFalg) + { + if(SUCCESS == sf_get_send_file_list(&SendFileList[0][0], &SendFileTotal)){ + if (fileCfg) { + ret = TRUE; + fileCfg->filecnt = SendFileTotal; + for(fileIndex = 0; fileIndex < SendFileTotal; fileIndex++) + { + if((SF_CAM_MODE_PHOTO_VIDEO == (SendFileList[fileIndex][0] - '0')) || (SF_CAM_MODE_VIDEO2 == (SendFileList[fileIndex][0] - '0'))){ + fileCfg->stfileattr[fileIndex].enFileTye = SF_FILE_TYPE_PIC_VIDEO; + }else if(SF_CAM_MODE_PHOTO == (SendFileList[fileIndex][0] - '0')){ + fileCfg->stfileattr[fileIndex].enFileTye = SF_FILE_TYPE_PIC_SMALL; + } + snprintf(fileCfg->stfileattr[fileIndex].thumbfileName, sizeof(fileCfg->stfileattr[fileIndex].thumbfileName), "%s", &SendFileList[fileIndex][1]); + snprintf(fileCfg->stfileattr[fileIndex].thumbfilePath, sizeof(fileCfg->stfileattr[fileIndex].thumbfilePath), "%s%s%s", SF_SD_ROOT, SF_SEND_LIST_DIR, + &SendFileList[fileIndex][1]); + printf("%s:%d thumbfileSize:%d thumbfileName:%s thumbfilePath:%s\n", __FUNCTION__, __LINE__, + fileCfg->stfileattr[fileIndex].thumbfileSize,fileCfg->stfileattr[fileIndex].thumbfileName,fileCfg->stfileattr[fileIndex].thumbfilePath); + } + } + } + } + UINT8 EmmcfileIndex = 0; + if(1 == EmmcSendFalg) + { + if(SUCCESS == sf_get_send_file_list_emmc(&SendFileList[0][0], &EmmcfileIndex)){ + if (fileCfg) { + ret = TRUE; + SendFileTotal = (fileCfg->filecnt + EmmcfileIndex) >= 200 ? 200: (fileCfg->filecnt + EmmcfileIndex); + fileCfg->filecnt = SendFileTotal; + for(fileIndex = 0; fileIndex < SendFileTotal; fileIndex++) + { + EmmcfileIndex--; + if((SF_CAM_MODE_PHOTO_VIDEO == (SendFileList[EmmcfileIndex][0] - '0')) || (SF_CAM_MODE_VIDEO2 == (SendFileList[EmmcfileIndex][0] - '0'))){ + fileCfg->stfileattr[fileIndex].enFileTye = SF_FILE_TYPE_PIC_VIDEO; + }else if(SF_CAM_MODE_PHOTO == (SendFileList[EmmcfileIndex][0] - '0')){ + fileCfg->stfileattr[fileIndex].enFileTye = SF_FILE_TYPE_PIC_SMALL; + } + snprintf(fileCfg->stfileattr[fileIndex].thumbfileName, sizeof(fileCfg->stfileattr[fileIndex].thumbfileName), "%s", &SendFileList[EmmcfileIndex][1]); + snprintf(fileCfg->stfileattr[fileIndex].thumbfilePath, sizeof(fileCfg->stfileattr[fileIndex].thumbfilePath), "%s%s%s", SF_EMMC_ROOT, SF_SEND_LIST_DIR, + &SendFileList[EmmcfileIndex][1]); + printf("%s:%d thumbfileSize:%d thumbfileName:%s thumbfilePath:%s\n", __FUNCTION__, __LINE__, + fileCfg->stfileattr[fileIndex].thumbfileSize,fileCfg->stfileattr[fileIndex].thumbfileName,fileCfg->stfileattr[fileIndex].thumbfilePath); + } + } + } + } printf("%s:%d e \n", __FUNCTION__, __LINE__); - free(strg_path); return ret; } diff --git a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c index 815834c38..be799446b 100644 --- a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c +++ b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c @@ -493,25 +493,28 @@ UINT32 sf_delete_send_flie_list(void) { UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); char tmp[64] = {'\0'}; - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return 1; - } - + if(0 == puiPara->SendType){ - snprintf(tmp, sizeof(tmp), "%s%s", strg_path, SF_THUMB_SEND_AUTO); + snprintf(tmp, sizeof(tmp), "%s%s", SF_EMMC_ROOT, SF_THUMB_SEND_AUTO); + if(sf_file_IsExsit(tmp) == SF_TRUE) + sf_file_remove(tmp); + + snprintf(tmp, sizeof(tmp), "%s%s", SF_SD_ROOT, SF_THUMB_SEND_AUTO); if(sf_file_IsExsit(tmp) == SF_TRUE) sf_file_remove(tmp); } else{ - snprintf(tmp, sizeof(tmp), "%s%s", strg_path, SF_THUMB_SEND_LIST); + snprintf(tmp, sizeof(tmp), "%s%s", SF_EMMC_ROOT, SF_THUMB_SEND_LIST); + printf("delete %s\n", SF_SEND_LIST_DIR); + if(sf_file_IsExsit(tmp) == SF_TRUE) + sf_file_remove(tmp); + + snprintf(tmp, sizeof(tmp), "%s%s", SF_SD_ROOT, SF_THUMB_SEND_LIST); printf("delete %s\n", SF_SEND_LIST_DIR); if(sf_file_IsExsit(tmp) == SF_TRUE) sf_file_remove(tmp); } - free(strg_path); + return 0; }