uapi_calendar_recover_date();
- int ret = uapi_save_exc();
- if(ret != 0)
- PRINT("exc file save failed \r\n");
- else
- PRINT("exc file save succed \r\n");
-
if(!custom_ble_service_on_flag())
{
stop_custom_ble_service();
//initializeMotionRecognition();
LOS_Msleep(5000);
+
+ int ret = uapi_save_exc();
+ if(ret != 0)
+ PRINT("exc file save failed \r\n");
+ else
+ {
+ PRINT("exc file save succed \r\n");
+ removeFilesInFolder("/user/exc");
+ }
+
addressbookToRead(NULL);
up_report_timer();
if ( poweron_cat1_on_bootup_flag() )
}
}
-int uapi_save_exc(void)
+int uapi_tar_file(const char *src_path,const char *tar_path,char *tarfilename)
{
- const char *folderPath = "/user/exc";
- const char *tarPath = "/user/tar";
- const char *tarfilePath = "/user/tar/exc_%d.tar";
-
+ //const char *tarfilePath = "%s/exc_%d.tar";
DIR *dir;
struct dirent *entry;
mtar_t tar;
size_t bytesRead = 0;
FILE *fp;
struct stat file_inf;
+ long tar_size = 0;
int ret = 0;
- if(access(folderPath, F_OK) == -1)
+ if(access(src_path, F_OK) == -1)
{
if(ret == -1)
{
- PRINT("%s does not exist!!!\r\n", folderPath);
+ PRINT("%s does not exist!!!\r\n", src_path);
return -1;
}
}
- dir = opendir(folderPath);
+ dir = opendir(src_path);
if (dir == NULL)
{
- PRINT("unable to open %s\r\n",folderPath);
+ PRINT("unable to open %s\r\n",src_path);
return -1;
}
- if((entry = readdir(dir)) == NULL)
+ if(access(tar_path, F_OK) == -1)
{
- PRINT("%s is empty\r\n",folderPath);
- return -1;
- }
-
- if(access(tarPath, F_OK) == -1)
- {
- ret = mkdir(tarPath, 0777);
+ ret = mkdir(tar_path, 0777);
if(ret == -1)
{
- PRINT("mkdir %s failed \r\n",tarPath);
+ PRINT("mkdir %s failed \r\n",tar_path);
return -1;
}
}
- uint32_t timestamp = get_local_timestamp();
- char *str = (char *)malloc(200);
- memset_s(str, 200, 0, 200);
- sprintf(str, tarfilePath, timestamp);
+ char str[200] = {0};
+ //snprintf(str, sizeof(str), tar_path,tarfilePath,timestamp);
+ sprintf(str, "%s/%s",tar_path,tarfilename);
+ PRINT("str %s \r\n",str);
+ //sprintf(str, tarfilePath, timestamp);
ret = mtar_open(&tar, str, "w");
if (ret != MTAR_ESUCCESS)
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
{
char filePath[64];
- snprintf(filePath, sizeof(filePath), "%s/%s", folderPath, entry->d_name);
+ snprintf(filePath, sizeof(filePath), "%s/%s", src_path, entry->d_name);
fp = fopen(filePath, "r");
if(fp == NULL)
memset(&file_inf, 0, sizeof(file_inf));
stat(filePath, &file_inf);
-
+ tar_size += file_inf.st_size;
mtar_write_file_header(&tar, entry->d_name, file_inf.st_size);
while((bytesRead = fread(buffer, 1, sizeof(buffer), fp)) > 0)
}
}
}
-
+
/* Finalize -- this needs to be the last thing done before closing */
mtar_finalize(&tar);
/* Close archive */
mtar_close(&tar);
closedir(dir);
- removeFilesInFolder(folderPath);
+ if(tar_size == 0)
+ {
+ PRINT("%s is empty\r\n",src_path);
+ remove(str);
+ return -1;
+ }
+ //free(str);
return ret;
}
+
+int uapi_save_exc(void)
+{
+ uint32_t timestamp = get_local_timestamp();
+ char *tarfilePath = "exc_%d.tar";
+ char str[200] = {0};
+ sprintf(str, tarfilePath, timestamp);
+ return uapi_tar_file("/user/exc","/user/tar",str);
+}
+
#include "driver/calendar.h"
uint32_t uapi_calendar_store_date(void)