From: penglei <1624952103@qq.com> Date: Sat, 8 Jun 2024 10:34:52 +0000 (+0800) Subject: 优化tar保存exc文件 X-Git-Tag: release_V1.2.70_20241020_135402~1018^2~6 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=0823904ec67e59a117d91dea556eb6e6d31ba863;p=mirrors%2FFD230.git 优化tar保存exc文件 --- diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 7bc3292cf..06e776f51 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1596,6 +1596,15 @@ int uapi_save_exc(void) struct stat file_inf; int ret = 0; + if(access(folderPath, F_OK) == -1) + { + if(ret == -1) + { + PRINT("%s does not exist!!!\r\n", folderPath); + return -1; + } + } + dir = opendir(folderPath); if (dir == NULL) { @@ -1603,6 +1612,12 @@ int uapi_save_exc(void) return -1; } + if((entry = readdir(dir)) == NULL) + { + PRINT("%s is empty\r\n",folderPath); + return -1; + } + if(access(tarPath, F_OK) == -1) { ret = mkdir(tarPath, 0777); @@ -1668,6 +1683,7 @@ int uapi_save_exc(void) /* Close archive */ mtar_close(&tar); closedir(dir); + removeFilesInFolder(folderPath); return ret; }