diff --git a/code/application/source/sf_app/code/include/sf_storeMng.h b/code/application/source/sf_app/code/include/sf_storeMng.h index 9d618e1b1..5683b9c31 100644 --- a/code/application/source/sf_app/code/include/sf_storeMng.h +++ b/code/application/source/sf_app/code/include/sf_storeMng.h @@ -92,7 +92,7 @@ char *sf_root_path_strcat(char *path_name); char *sf_get_root_path(void); SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs); - +SINT32 sf_emmc_info_get(SF_STORE_ATTR_S *pstoreattrs); SINT32 sf_sd_remove_file(const char *path,SINT32 threshold) ; SINT32 sf_sd_loopremove(const char *path); 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 be799446b..642ca2bbe 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 @@ -209,6 +209,44 @@ SINT32 sf_sd_isfull(SINT8 *Isfull) *Isfull = (storeattrs.SDFree <= SD_WARNING_SPACE)?1:0; return SF_SUCCESS; } +SINT32 sf_emmc_info_get(SF_STORE_ATTR_S *pstoreattrs) +{ + SF_COMM_CHECK_POINTER(pstoreattrs,SF_FAILURE); + + SINT32 fd = -1; + fd = open(SF_EMMC_ROOT, O_RDONLY,0); + if(fd >= 0) + { + struct statfs diskInfo; + statfs(SF_EMMC_ROOT, &diskInfo); + if(diskInfo.f_bsize > 1024) + { + pstoreattrs->SDTotalSize = (diskInfo.f_blocks * (diskInfo.f_bsize >> 10)) >> 10 ; //blocks * 4096 / 1024 /1024 = MB + pstoreattrs->SDFree = (diskInfo.f_bavail * (diskInfo.f_bsize >> 10)) >> 10 ; + } + else + { + pstoreattrs->SDTotalSize = (diskInfo.f_blocks * diskInfo.f_bsize) >> 10 ; //blocks * 4096 / 1024 /1024 = MB + pstoreattrs->SDFree = (diskInfo.f_bavail * diskInfo.f_bsize) >> 10 ; + } + close(fd); + + if(pstoreattrs->SDTotalSize > 0) + pstoreattrs->SDStatus = 0; //SD card SUCESS + else + pstoreattrs->SDStatus = 2; //SD card ERROR + } + else + { + pstoreattrs->SDStatus = 1; //SD card not insert + pstoreattrs->SDFree = 0; + pstoreattrs->SDTotalSize = 0; + return SF_FAILURE; + } + + MLOGD("EmmcStatus = %d,EmmcFree = %d MB,EmmcTotalSize = %d MB\n", pstoreattrs->SDStatus, pstoreattrs->SDFree,pstoreattrs->SDTotalSize); + return SF_SUCCESS; +} SINT32 sf_sd_remove_file(const char *path,SINT32 threshold) { SF_COMM_CHECK_POINTER(path,SF_FAILURE); @@ -800,16 +838,9 @@ int sf_dcf_resort_min(void) char sTmp[SF_DCF_FILENAME_LEN_MAX] = {0}; int nmax_dirkey = 0; int nmin_dirkey = 0; - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return SF_FAILURE; - } - strcpy(sRootPath, strg_path); // "/mnt/sd/" - strcat(sRootPath, SF_DCF_ROOT_DIR_NAME); // ""/mnt/sd/DCIM/" - free(strg_path); + strcpy(sRootPath, SF_EMMC_ROOT); // "/mnt/sd2/" + strcat(sRootPath, SF_DCF_ROOT_DIR_NAME); // ""/mnt/sd2/DCIM/" trave_dir(sRootPath,0); MLOGD("gnDirIdx:%d,gDirList:%d\n", gnDirIdx, gnDirList[gnDirIdx-1]); @@ -879,20 +910,12 @@ int sf_app_sd_loop(void) nFileKey = gLastFileKey; MLOGD(" s\n"); - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return SF_FAILURE; - } - char font = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_HANDLE : SF_SD_DCF_HANDLE; - char *dcf_file = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_FILE_NAME : SF_SD_DCF_FILE_NAME; - + while((nloop) && (dircount < 5)) { - sprintf(cPathTmp,"%s%s/%03d%s", strg_path, SF_DCF_ROOT_DIR_NAME, nDirKey, DCF_DIR_NAME); // ""/mnt/sd/DCIM/100MEDIA" + sprintf(cPathTmp,"%s%s/%03d%s", SF_EMMC_ROOT, SF_DCF_ROOT_DIR_NAME, nDirKey, DCF_DIR_NAME); // ""/mnt/sd/DCIM/100MEDIA" //Not Empty,Record File Name - sprintf(cFileTmp, "%s/%s%04d.%s",cPathTmp, dcf_file, nFileKey, SF_DCF_EXT_PHOTO); + sprintf(cFileTmp, "%s/%s%04d.%s",cPathTmp, SF_EMMC_DCF_FILE_NAME, nFileKey, SF_DCF_EXT_PHOTO); if(access(cFileTmp,R_OK) == 0) { @@ -902,7 +925,7 @@ int sf_app_sd_loop(void) } else { - sprintf(cFileTmp, "%s/%s%04d.%s", cPathTmp, dcf_file, nFileKey, SF_DCF_EXT_MOV); + sprintf(cFileTmp, "%s/%s%04d.%s", cPathTmp, SF_EMMC_DCF_FILE_NAME, nFileKey, SF_DCF_EXT_MOV); if(access(cFileTmp,R_OK) == 0) { MLOGD("Will Delete File Name:%s\n", cFileTmp); @@ -928,7 +951,7 @@ int sf_app_sd_loop(void) } } - sprintf(cFileTmp,"%s%s/W%c%03d%04d.JPG", strg_path, SF_DCF_THM_DIR_NAME, font, nDirKey, nFileKey); + sprintf(cFileTmp,"%s%s/W%c%03d%04d.JPG", SF_EMMC_ROOT, SF_DCF_THM_DIR_NAME, SF_EMMC_DCF_HANDLE, nDirKey, nFileKey); //MLOGD("Thumb Filename:%s\n", cFileTmp); if(access(cFileTmp,R_OK) == 0) { @@ -936,7 +959,7 @@ int sf_app_sd_loop(void) remove(cFileTmp); } - sprintf(cFileTmp,"%s%s/S%c%03d%04d.JPG", strg_path, SF_DCF_THM_DIR_NAME, font, nDirKey, nFileKey); + sprintf(cFileTmp,"%s%s/S%c%03d%04d.JPG", SF_EMMC_ROOT, SF_DCF_THM_DIR_NAME, SF_EMMC_DCF_HANDLE, nDirKey, nFileKey); //MLOGD("Thumb Filename:%s\n", cFileTmp); if(access(cFileTmp,R_OK) == 0) { @@ -947,7 +970,7 @@ int sf_app_sd_loop(void) if(iFileCount % 20 == 0) { //sf_get_sd_info(&sdStatus, &sdFree, &sdTotal); - sf_sd_info_get(&storeattrs); + sf_emmc_info_get(&storeattrs); if(storeattrs.SDFree > (SDLOOP_REMAIN_SPACE+50)) { @@ -981,8 +1004,7 @@ int sf_app_sd_loop(void) } } - sync(); - free(strg_path); + system("sync"); return 0; }