strgMng存储路径动态获取

This commit is contained in:
sober.song 2023-12-30 20:54:10 +08:00
parent 2bf30912db
commit 4879e7cc94
8 changed files with 106 additions and 18 deletions

View File

@ -939,6 +939,8 @@
#define SF_HD_DIR SF_SEND_LIST_DIR"HD" #define SF_HD_DIR SF_SEND_LIST_DIR"HD"
#define SF_HD_DIR_CARDV "A:\\THUMB\\HD\\" #define SF_HD_DIR_CARDV "A:\\THUMB\\HD\\"
#define SF_EMMC_ROOT "/mnt/sd2/"
#define SF_FW_CFG_FILE_NAME "SPHOST_REVEAL.CFG" #define SF_FW_CFG_FILE_NAME "SPHOST_REVEAL.CFG"
#define SF_FW_FILE_NAME "SPHOST_REVEAL.BRN" #define SF_FW_FILE_NAME "SPHOST_REVEAL.BRN"
#define SF_FW_CFG_FILE_PATH "A:\\SPHOST_REVEAL.CFG" #define SF_FW_CFG_FILE_PATH "A:\\SPHOST_REVEAL.CFG"

View File

@ -56,6 +56,13 @@ typedef struct sf_STORE_ATTR_S {
}SF_STORE_ATTR_S; }SF_STORE_ATTR_S;
typedef enum
{
MMC_DEV_SD = 0,
MMC_DEV_EMMC = 1,
MMC_DEV_NO = 2,
}MMC_DEV_TYPE;
SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs); SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs);

View File

@ -1366,6 +1366,11 @@ SINT32 sf_4g_module_ota_ftp(void)
const UINT8 *password; const UINT8 *password;
// FtpConfig config; // FtpConfig config;
MLOGD("start\n"); MLOGD("start\n");
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
ssl_flag = FTP_SSL_FLAG_DISABLE; ssl_flag = FTP_SSL_FLAG_DISABLE;
ftpIP = pPara->OtaFtpIp; ftpIP = pPara->OtaFtpIp;
@ -1395,7 +1400,7 @@ SINT32 sf_4g_module_ota_ftp(void)
ret = ftp_download_file(SF_MODULE_UP_FILE,SF_MODULE_UP_FILE_PATH,0); ret = ftp_download_file(SF_MODULE_UP_FILE,SF_MODULE_UP_FILE_PATH,0);
if(SUCCESS == ret){ if(SUCCESS == ret){
system("sync"); system("sync");
sprintf(Cmd, "tar -xjvf %s -C %s", SF_MODULE_UP_FILE_PATH, SF_SD_ROOT); sprintf(Cmd, "tar -xjvf %s -C %s", SF_MODULE_UP_FILE_PATH, strg_path);
MLOGD("%s\n", Cmd); MLOGD("%s\n", Cmd);
ret = system(Cmd); ret = system(Cmd);
if(SUCCESS == ret){ if(SUCCESS == ret){

View File

@ -871,6 +871,11 @@ SINT16 sf_thumb_file_creat(void) {
SF_CHAR fileKeyStr[10] = {0}; SF_CHAR fileKeyStr[10] = {0};
SF_CHAR filePathStr[128] = {0}; SF_CHAR filePathStr[128] = {0};
SINT16 fileIndex = 0; SINT16 fileIndex = 0;
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
SF_SRCFILE_ATTR_S *fileCfg = sf_file_thumb_cfg_get(); SF_SRCFILE_ATTR_S *fileCfg = sf_file_thumb_cfg_get();
for (fileIndex = 0; fileIndex < fileCfg->filecnt; fileIndex++) { for (fileIndex = 0; fileIndex < fileCfg->filecnt; fileIndex++) {
@ -879,7 +884,7 @@ SINT16 sf_thumb_file_creat(void) {
strncpy(dirKeyStr, fileCfg->stfileattr[fileIndex].thumbfileName + 1, 3); strncpy(dirKeyStr, fileCfg->stfileattr[fileIndex].thumbfileName + 1, 3);
strncpy(fileKeyStr, fileCfg->stfileattr[fileIndex].thumbfileName + 4, 8); strncpy(fileKeyStr, fileCfg->stfileattr[fileIndex].thumbfileName + 4, 8);
MLOGD("dirKeyStr:%s, fileKeyStr:%s\n", dirKeyStr, fileKeyStr); MLOGD("dirKeyStr:%s, fileKeyStr:%s\n", dirKeyStr, fileKeyStr);
sprintf(filePathStr, "%s%s/%s%s/%s%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME, sprintf(filePathStr, "%s%s/%s%s/%s%s", strg_path, SF_DCF_ROOT_DIR_NAME,
dirKeyStr, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX, dirKeyStr, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,
fileKeyStr); fileKeyStr);
MLOGD("fileKeyStr:%s\n", filePathStr); MLOGD("fileKeyStr:%s\n", filePathStr);

View File

@ -1452,7 +1452,14 @@ BOOL sf_is_4g_module_usb_update_file_exist(UINT8 *updateFname)
struct dirent *ptr = NULL; struct dirent *ptr = NULL;
UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
if ((dirp=opendir((char *)SF_SD_ROOT)) != NULL)
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return FALSE;
}
if ((dirp=opendir((char *)strg_path)) != NULL)
{ {
while ((ptr=readdir(dirp)) != NULL) while ((ptr=readdir(dirp)) != NULL)
{ {
@ -1462,7 +1469,7 @@ BOOL sf_is_4g_module_usb_update_file_exist(UINT8 *updateFname)
{ {
if(SF_STRNCMP(ptr->d_name, puiPara->ModuleVer, 6) == 0) if(SF_STRNCMP(ptr->d_name, puiPara->ModuleVer, 6) == 0)
{ {
SF_SPRINTF(updateFname, "%s%s", SF_SD_ROOT, ptr->d_name); SF_SPRINTF(updateFname, "%s%s", strg_path, ptr->d_name);
closedir(dirp); closedir(dirp);
printf("[%s:%d] updateFname:%s\n", __FUNCTION__, __LINE__, updateFname); printf("[%s:%d] updateFname:%s\n", __FUNCTION__, __LINE__, updateFname);
return TRUE; return TRUE;

View File

@ -310,7 +310,12 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SUBSCRIBE_ATTR_S
memset(pstfileAttr->txtfileName, '\0', sizeof(pstfileAttr->txtfileName)); memset(pstfileAttr->txtfileName, '\0', sizeof(pstfileAttr->txtfileName));
memset(pstfileAttr->txtfilePath, '\0', sizeof(pstfileAttr->txtfilePath)); memset(pstfileAttr->txtfilePath, '\0', sizeof(pstfileAttr->txtfilePath));
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
switch(pSubscribe->subscribeType) switch(pSubscribe->subscribeType)
{ {
case SF_SUBSCRIBE_VIDEO: case SF_SUBSCRIBE_VIDEO:
@ -345,7 +350,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SUBSCRIBE_ATTR_S
strncpy(fileName, pSubscribe->subscribeFileName + (strlen(pSubscribe->subscribeFileName) - 12), 12); strncpy(fileName, pSubscribe->subscribeFileName + (strlen(pSubscribe->subscribeFileName) - 12), 12);
fileKey = atoi(fileName+4); fileKey = atoi(fileName+4);
MLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey); MLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey);
sprintf(filePath, "%s%s/%03d%s/%s%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4); sprintf(filePath, "%s%s/%03d%s/%s%s", strg_path, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4);
MLOGD("srcFile:%s\n", filePath); MLOGD("srcFile:%s\n", filePath);
ret = sf_file_IsExsit((CHAR*)filePath); ret = sf_file_IsExsit((CHAR*)filePath);
@ -359,7 +364,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SUBSCRIBE_ATTR_S
} }
break; break;
case SF_SUBSCRIBE_SPEC_FILE: case SF_SUBSCRIBE_SPEC_FILE:
sprintf(filePath, "%s%s", SF_SD_ROOT,"SF_GPS.TXT" ); sprintf(filePath, "%s%s", strg_path,"SF_GPS.TXT" );
MLOGD("srcFile:%s\n", filePath); MLOGD("srcFile:%s\n", filePath);
ret = sf_file_IsExsit((CHAR*)filePath); ret = sf_file_IsExsit((CHAR*)filePath);
@ -540,6 +545,11 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S*
memset(pstfileAttr->txtfileName, '\0', sizeof(pstfileAttr->txtfileName)); memset(pstfileAttr->txtfileName, '\0', sizeof(pstfileAttr->txtfileName));
memset(pstfileAttr->txtfilePath, '\0', sizeof(pstfileAttr->txtfilePath)); memset(pstfileAttr->txtfilePath, '\0', sizeof(pstfileAttr->txtfilePath));
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
switch(pSendFileAttr->enFileTye) switch(pSendFileAttr->enFileTye)
{ {
@ -554,7 +564,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S*
strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 12), 12); strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 12), 12);
fileKey = atoi(fileName+4); fileKey = atoi(fileName+4);
SLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey); SLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey);
sprintf(filePath, "%s%s/%03d%s/%s%04d.%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileKey,SF_DCF_EXT_MOV); sprintf(filePath, "%s%s/%03d%s/%s%04d.%s", strg_path, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileKey,SF_DCF_EXT_MOV);
SLOGD("srcFile:%s\n", filePath); SLOGD("srcFile:%s\n", filePath);
// strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 11), 8); // strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 11), 8);
@ -583,7 +593,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S*
strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 12), 12); strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 12), 12);
fileKey = atoi(fileName+4); fileKey = atoi(fileName+4);
SLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey); SLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey);
sprintf(filePath, "%s%s/%03d%s/%s%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4); sprintf(filePath, "%s%s/%03d%s/%s%s", strg_path, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4);
SLOGD("srcFile:%s\n", filePath); SLOGD("srcFile:%s\n", filePath);
ret = sf_file_IsExsit((CHAR*)filePath); ret = sf_file_IsExsit((CHAR*)filePath);
@ -601,7 +611,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S*
break; break;
case SF_FILE_TYPE_LOG_ERROR: case SF_FILE_TYPE_LOG_ERROR:
sprintf(filePath, "%s%s", SF_SD_ROOT,"SF_GPS.TXT" ); sprintf(filePath, "%s%s", strg_path,"SF_GPS.TXT" );
SLOGD("srcFile:%s\n", filePath); SLOGD("srcFile:%s\n", filePath);
ret = sf_file_IsExsit((CHAR*)filePath); ret = sf_file_IsExsit((CHAR*)filePath);

View File

@ -37,6 +37,8 @@ UINT32 gnDirIdx = 0;
static SF_SD_STATUS_E SdStatus = SF_SD_BUTT; static SF_SD_STATUS_E SdStatus = SF_SD_BUTT;
MMC_DEV_TYPE mmc_dev = MMC_DEV_NO;
static SINT32 sd_file_Isexsit(SF_CHAR *fileName) static SINT32 sd_file_Isexsit(SF_CHAR *fileName)
{ {
return access(fileName, F_OK); return access(fileName, F_OK);
@ -76,16 +78,49 @@ static SINT32 sd_Isdirempty(char *dirname)
return SF_SUCCESS; return SF_SUCCESS;
} }
void sf_set_workable_strg_id(UINT32 strg_id)
{
mmc_dev = strg_id;
}
MMC_DEV_TYPE sf_get_workable_strg_id(void)
{
return mmc_dev;
}
char *sf_get_root_path(void)
{
char *strg_path = NULL;
if(mmc_dev == MMC_DEV_NO)
{
return NULL;
}
if(sf_get_workable_strg_id() == MMC_DEV_SD){
strg_path = SF_SD_ROOT;
}else if(sf_get_workable_strg_id() == MMC_DEV_EMMC){
strg_path = SF_EMMC_ROOT;
}
return strg_path;
}
SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs) SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs)
{ {
SF_COMM_CHECK_POINTER(pstoreattrs,SF_FAILURE); SF_COMM_CHECK_POINTER(pstoreattrs,SF_FAILURE);
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
SINT32 fd = -1; SINT32 fd = -1;
fd = open(SF_SD_ROOT, O_RDONLY,0); fd = open(strg_path, O_RDONLY,0);
if(fd >= 0) if(fd >= 0)
{ {
struct statfs diskInfo; struct statfs diskInfo;
statfs(SF_SD_ROOT, &diskInfo); statfs(strg_path, &diskInfo);
if(diskInfo.f_bsize > 1024) if(diskInfo.f_bsize > 1024)
{ {
@ -704,8 +739,13 @@ int sf_dcf_resort_min(void)
char sTmp[SF_DCF_FILENAME_LEN_MAX] = {0}; char sTmp[SF_DCF_FILENAME_LEN_MAX] = {0};
int nmax_dirkey = 0; int nmax_dirkey = 0;
int nmin_dirkey = 0; int nmin_dirkey = 0;
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
strcpy(sRootPath, SF_SD_ROOT); // "/mnt/sd/" strcpy(sRootPath, strg_path); // "/mnt/sd/"
strcat(sRootPath, SF_DCF_ROOT_DIR_NAME); // ""/mnt/sd/DCIM/" strcat(sRootPath, SF_DCF_ROOT_DIR_NAME); // ""/mnt/sd/DCIM/"
trave_dir(sRootPath,0); trave_dir(sRootPath,0);
@ -776,10 +816,15 @@ int sf_app_sd_loop(void)
nFileKey = gLastFileKey; nFileKey = gLastFileKey;
MLOGD(" s\n"); MLOGD(" s\n");
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
while((nloop) && (dircount < 5)) while((nloop) && (dircount < 5))
{ {
sprintf(cPathTmp,"%s%s/%03d%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME, nDirKey, DCF_DIR_NAME); // ""/mnt/sd/DCIM/100MEDIA" sprintf(cPathTmp,"%s%s/%03d%s", strg_path, SF_DCF_ROOT_DIR_NAME, nDirKey, DCF_DIR_NAME); // ""/mnt/sd/DCIM/100MEDIA"
//Not Empty,Record File Name //Not Empty,Record File Name
sprintf(cFileTmp, "%s/%s%04d.%s",cPathTmp, DCF_FILE_NAME, nFileKey, SF_DCF_EXT_PHOTO); sprintf(cFileTmp, "%s/%s%04d.%s",cPathTmp, DCF_FILE_NAME, nFileKey, SF_DCF_EXT_PHOTO);
@ -817,7 +862,7 @@ int sf_app_sd_loop(void)
} }
} }
sprintf(cFileTmp,"%s%s/W%03d%04d.JPG", SF_SD_ROOT, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey); sprintf(cFileTmp,"%s%s/W%03d%04d.JPG", strg_path, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey);
//MLOGD("Thumb Filename:%s\n", cFileTmp); //MLOGD("Thumb Filename:%s\n", cFileTmp);
if(access(cFileTmp,R_OK) == 0) if(access(cFileTmp,R_OK) == 0)
{ {
@ -825,7 +870,7 @@ int sf_app_sd_loop(void)
remove(cFileTmp); remove(cFileTmp);
} }
sprintf(cFileTmp,"%s%s/S%03d%04d.JPG", SF_SD_ROOT, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey); sprintf(cFileTmp,"%s%s/S%03d%04d.JPG", strg_path, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey);
//MLOGD("Thumb Filename:%s\n", cFileTmp); //MLOGD("Thumb Filename:%s\n", cFileTmp);
if(access(cFileTmp,R_OK) == 0) if(access(cFileTmp,R_OK) == 0)
{ {

View File

@ -1110,6 +1110,13 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
SF_MESSAGE_BUF_S stMessageBuf = {0}; SF_MESSAGE_BUF_S stMessageBuf = {0};
// HI_MESSAGE_S stMessage; // HI_MESSAGE_S stMessage;
char *strg_path = sf_get_root_path();
if(strg_path == NULL)
{
return SF_FAILURE;
}
//printf("[sf_svr_packet_proc]dataLen: %d\n",dataLen); //printf("[sf_svr_packet_proc]dataLen: %d\n",dataLen);
if(poweroff_mode == POWEROFF_COUNTDOWN) if(poweroff_mode == POWEROFF_COUNTDOWN)
@ -1324,7 +1331,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
strncpy((char *)tempbuf2, (char *)tempbuf, 3); strncpy((char *)tempbuf2, (char *)tempbuf, 3);
tempbuf[8] = '\0'; tempbuf[8] = '\0';
sprintf((char *)gFileName, "%sDCIM/%s%s/%s%s%s", sprintf((char *)gFileName, "%sDCIM/%s%s/%s%s%s",
SF_SD_ROOT, strg_path,
tempbuf2, tempbuf2,
DCF_DIR_NAME, DCF_DIR_NAME,
DCF_FILE_NAME, DCF_FILE_NAME,
@ -1874,7 +1881,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
} }
else else
{ {
sprintf((char *)fileName, "%s%s",SF_SD_ROOT,pMsgStruct->msgBuf.ctrlFileTransfer.fileName); sprintf((char *)fileName, "%s%s",strg_path,pMsgStruct->msgBuf.ctrlFileTransfer.fileName);
} }
//MLOGI("rec file cmd:%s\n", fileName); //MLOGI("rec file cmd:%s\n", fileName);
} }