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)
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)