优化删除文件函数
authorCaisking <3449750381@qq.com>
Wed, 12 Jun 2024 07:40:18 +0000 (15:40 +0800)
committerCaisking <3449750381@qq.com>
Wed, 12 Jun 2024 07:40:18 +0000 (15:40 +0800)
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index 18b7608..630eea7 100644 (file)
@@ -1587,8 +1587,8 @@ int removeFilesInFolder(const char *folderPath)
     closedir(dir);
     return ret;
 }
-
-void uapi_delete_files(const char *file_path)
+/*删除文件*/
+int uapi_delete_files(const char *file_path)
 {
        struct stat s_buf;
     int ret = 0;
@@ -1596,7 +1596,7 @@ void uapi_delete_files(const char *file_path)
     if(access(file_path, F_OK) == -1)
     {
         PRINT("%s does not exist!!!\r\n", file_path);
-        return;
+        return 0 ;
     }
     stat(file_path,&s_buf);
     if(S_ISDIR(s_buf.st_mode))
@@ -1604,9 +1604,16 @@ void uapi_delete_files(const char *file_path)
     else
         ret = remove(file_path);
     if(ret != 0)
+    {
         PRINT("%s remove failed !!! \r\n",file_path);
+        return 0;
+    }
     else
+    {
         PRINT("%s remove succeed !!! \r\n",file_path);
+        return 1;
+    }
+        
 }
 
 int uapi_tar_file(const char *src_path,const char *tar_path,char *tarfilename)
index d595115..574d8db 100644 (file)
@@ -177,7 +177,7 @@ uint32_t uapi_calendar_store_date(void);
 
 errcode_t uapi_custom_cmd_service_init(void);
 void do_custom_cmd_service_check_msg(int cmd, void *params, int paramlen);
-void uapi_delete_files(const char *file_path);
+int uapi_delete_files(const char *file_path);
 void uapi_restore_factory_setting(void);
 
 void custom_i2c_reset(void);