From: penglei <1624952103@qq.com> Date: Sat, 8 Jun 2024 04:05:03 +0000 (+0800) Subject: 补交 X-Git-Tag: release_V1.2.70_20241020_135402~1018^2~11 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F244%2F2;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 a3a32f7c8..9a683eac8 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1577,7 +1577,7 @@ void uapi_delete_files(void) int uapi_save_exc(void) { - const char *folderPath = "/user/exc"; + const char *folderPath = "/user/exc"; const char *tarPath = "/user/tar/exc_%d.tar"; DIR *dir; @@ -1589,6 +1589,7 @@ int uapi_save_exc(void) size_t bytesRead = 0; FILE *fp; + struct stat file_inf; int ret = 0; uint32_t timestamp = get_local_timestamp(); @@ -1599,14 +1600,14 @@ int uapi_save_exc(void) ret = mtar_open(&tar, str, "w"); if (ret != MTAR_ESUCCESS) { - PRINT("Unable to open/create %s\r\n",str); + PRINT("unable to open/create %s\r\n",str); return -1; } dir = opendir(folderPath); if (dir == NULL) { - PRINT("Unable to open %s\r\n",folderPath); + PRINT("unable to open %s\r\n",folderPath); return -1; } @@ -1615,18 +1616,22 @@ int uapi_save_exc(void) if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { char filePath[64]; - snprintf(filePath, sizeof(filePath), "%s/%s", filePath, entry->d_name); + snprintf(filePath, sizeof(filePath), "%s/%s", folderPath, entry->d_name); fp = fopen(filePath, "r"); if(fp == NULL) { - PRINT("Unable to open %s\n", filePath); + PRINT("uable to open %s\r\n", filePath); return -1; } - while ((bytesRead = fread(buffer, 1, sizeof(buffer), fp) > 0) ) + memset(&file_inf, 0, sizeof(file_inf)); + stat(filePath, &file_inf); + + mtar_write_file_header(&tar, entry->d_name, file_inf.st_size); + + while((bytesRead = fread(buffer, 1, sizeof(buffer), fp)) > 0) { - mtar_write_file_header(&tar, entry->d_name, bytesRead); mtar_write_data(&tar, buffer, bytesRead); memset(buffer, 0, sizeof(buffer));