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;
size_t bytesRead = 0;
FILE *fp;
+ struct stat file_inf;
int ret = 0;
uint32_t timestamp = get_local_timestamp();
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;
}
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));