فهرست منبع

simplify subfolder creation

jblanked 9 ماه پیش
والد
کامیت
e8be8abe99
5فایلهای تغییر یافته به همراه48 افزوده شده و 33 حذف شده
  1. 8 8
      callback/callback.c
  2. 14 10
      explore/explore.c
  3. 7 1
      feed/feed.c
  4. 7 4
      friends/friends.c
  5. 12 10
      messages/messages.c

+ 8 - 8
callback/callback.c

@@ -2542,14 +2542,14 @@ bool callback_get_home_notification(FlipperHTTP *fhttp)
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         return false;
         return false;
     }
     }
-    // Create the directory for saving settings
-    char directory_path[256];
-    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/data");
-
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory_path);
-    furi_record_close(RECORD_STORAGE);
+
+    // create the data directory
+    if (!flip_social_subfolder_mkdir("data"))
+    {
+        FURI_LOG_E(TAG, "Failed to create data directory");
+        return false;
+    }
+
     alloc_headers();
     alloc_headers();
 
 
     snprintf(
     snprintf(

+ 14 - 10
explore/explore.c

@@ -10,17 +10,20 @@ bool explore_fetch(FlipperHTTP *fhttp)
         FURI_LOG_E(TAG, "App instance is NULL");
         FURI_LOG_E(TAG, "App instance is NULL");
         return false;
         return false;
     }
     }
+
     if (!fhttp)
     if (!fhttp)
     {
     {
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         return false;
         return false;
     }
     }
-    char directory[128];
-    snprintf(directory, sizeof(directory), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/explore");
 
 
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory);
+    // create the explore directory
+    if (!flip_social_subfolder_mkdir("explore"))
+    {
+        FURI_LOG_E(TAG, "Failed to create explore directory");
+        return false;
+    }
+
     char *keyword = !app_instance->explore_logged_in || strlen(app_instance->explore_logged_in) == 0 ? "a" : app_instance->explore_logged_in;
     char *keyword = !app_instance->explore_logged_in || strlen(app_instance->explore_logged_in) == 0 ? "a" : app_instance->explore_logged_in;
     snprintf(
     snprintf(
         fhttp->file_path,
         fhttp->file_path,
@@ -53,12 +56,13 @@ bool explore_fetch_2(FlipperHTTP *fhttp)
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         return false;
         return false;
     }
     }
-    char directory[128];
-    snprintf(directory, sizeof(directory), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/explore");
+    // create the explore directory
+    if (!flip_social_subfolder_mkdir("explore"))
+    {
+        FURI_LOG_E(TAG, "Failed to create explore directory");
+        return false;
+    }
 
 
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory);
     char *keyword = !app_instance->message_users_logged_in || strlen(app_instance->message_users_logged_in) == 0 ? "a" : app_instance->message_users_logged_in;
     char *keyword = !app_instance->message_users_logged_in || strlen(app_instance->message_users_logged_in) == 0 ? "a" : app_instance->message_users_logged_in;
     snprintf(
     snprintf(
         fhttp->file_path,
         fhttp->file_path,

+ 7 - 1
feed/feed.c

@@ -20,10 +20,16 @@ bool feed_fetch(FlipperHTTP *fhttp, int series_index)
         FURI_LOG_E(TAG, "Username is NULL");
         FURI_LOG_E(TAG, "Username is NULL");
         return false;
         return false;
     }
     }
+    // create the feed directory
+    if (!flip_social_subfolder_mkdir("feed"))
+    {
+        FURI_LOG_E(TAG, "Failed to create feed directory");
+        return false;
+    }
     snprintf(
     snprintf(
         fhttp->file_path,
         fhttp->file_path,
         sizeof(fhttp->file_path),
         sizeof(fhttp->file_path),
-        STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/feed.json");
+        STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/feed/feed.json");
 
 
     fhttp->save_received_data = true;
     fhttp->save_received_data = true;
     alloc_headers();
     alloc_headers();

+ 7 - 4
friends/friends.c

@@ -15,10 +15,13 @@ bool friends_fetch(FlipperHTTP *fhttp)
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         FURI_LOG_E(TAG, "FlipperHTTP is NULL");
         return false;
         return false;
     }
     }
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/friends");
-    furi_record_close(RECORD_STORAGE);
+
+    // create the friends directory
+    if (!flip_social_subfolder_mkdir("friends"))
+    {
+        FURI_LOG_E(TAG, "Failed to create friends directory");
+        return false;
+    }
 
 
     char url[100];
     char url[100];
     snprintf(
     snprintf(

+ 12 - 10
messages/messages.c

@@ -72,12 +72,13 @@ bool messages_get_message_users(FlipperHTTP *fhttp)
         FURI_LOG_E(TAG, "Username is NULL");
         FURI_LOG_E(TAG, "Username is NULL");
         return false;
         return false;
     }
     }
-    char directory[128];
-    snprintf(directory, sizeof(directory), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/messages");
+    // create the messages directory
+    if (!flip_social_subfolder_mkdir("messages"))
+    {
+        FURI_LOG_E(TAG, "Failed to create messages directory");
+        return false;
+    }
 
 
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory);
     char command[128];
     char command[128];
     snprintf(
     snprintf(
         fhttp->file_path,
         fhttp->file_path,
@@ -120,12 +121,13 @@ bool messages_get_messages_with_user(FlipperHTTP *fhttp)
         FURI_LOG_E(TAG, "Username is NULL");
         FURI_LOG_E(TAG, "Username is NULL");
         return false;
         return false;
     }
     }
-    char directory[128];
-    snprintf(directory, sizeof(directory), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/messages");
 
 
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory);
+    // create the messages directory
+    if (!flip_social_subfolder_mkdir("messages"))
+    {
+        FURI_LOG_E(TAG, "Failed to create messages directory");
+        return false;
+    }
 
 
     char command[256];
     char command[256];
     snprintf(
     snprintf(