From 0823904ec67e59a117d91dea556eb6e6d31ba863 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Sat, 8 Jun 2024 18:34:52 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96tar=E4=BF=9D=E5=AD=98exc?= =?utf8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- code/sdk/drivers/peripheral/utils/custom_utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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; } -- 2.17.1