From: penglei <1624952103@qq.com> Date: Sat, 8 Jun 2024 05:14:11 +0000 (+0800) Subject: 补交 X-Git-Tag: release_V1.2.70_20241020_135402~1018^2~10 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F244%2F3;p=mirrors%2FFD230.git 补交 --- diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 9a683eac8..0a007d816 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1578,24 +1578,39 @@ void uapi_delete_files(void) int uapi_save_exc(void) { const char *folderPath = "/user/exc"; - const char *tarPath = "/user/tar/exc_%d.tar"; + const char *tarPath = "/user/tar"; + const char *tarfilePath = "/user/tar/exc_%d.tar"; DIR *dir; struct dirent *entry; - mtar_t tar; - char buffer[1024]; - size_t bytesRead = 0; FILE *fp; struct stat file_inf; int ret = 0; + dir = opendir(folderPath); + if (dir == NULL) + { + PRINT("unable to open %s\r\n",folderPath); + return -1; + } + + if(access(tarPath, F_OK) == -1) + { + ret = mkdir(tarPath, 0777); + if(ret == -1) + { + PRINT("mkdir %s failed \r\n",tarPath); + return -1; + } + } + uint32_t timestamp = get_local_timestamp(); char *str = (char *)malloc(200); memset_s(str, 200, 0, 200); - sprintf(str, tarPath, timestamp); + sprintf(str, tarfilePath, timestamp); ret = mtar_open(&tar, str, "w"); if (ret != MTAR_ESUCCESS) @@ -1604,13 +1619,6 @@ int uapi_save_exc(void) return -1; } - dir = opendir(folderPath); - if (dir == NULL) - { - PRINT("unable to open %s\r\n",folderPath); - return -1; - } - while ((entry = readdir(dir)) != NULL) { if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)