Просмотр исходного кода

MassStorage: Format new images to exFAT automatically

Willy-JL 1 год назад
Родитель
Сommit
f3eff033b9
1 измененных файлов с 4 добавлено и 6 удалено
  1. 4 6
      mass_storage/scenes/mass_storage_scene_create_image.c

+ 4 - 6
mass_storage/scenes/mass_storage_scene_create_image.c

@@ -127,8 +127,6 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
             const char* error = NULL;
             const char* error = NULL;
             bool success = false;
             bool success = false;
 
 
-            size_t wipe_4k = 4096;
-            uint8_t* buffer = malloc(wipe_4k);
             do {
             do {
                 if(!storage_file_open(
                 if(!storage_file_open(
                        app->file,
                        app->file,
@@ -141,13 +139,13 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
                 if(size == app->create_image_max) size--;
                 if(size == app->create_image_max) size--;
                 if(!storage_file_expand(app->file, size)) break;
                 if(!storage_file_expand(app->file, size)) break;
 
 
-                // Zero out first 4k - partition table and adjacent data
-                if(!storage_file_seek(app->file, 0, true)) break;
-                if(!storage_file_write(app->file, buffer, wipe_4k)) break;
+                // Format as exFAT
+                if(storage_virtual_init(app->fs_api, app->file) != FSE_OK) break;
+                if(storage_virtual_format(app->fs_api) != FSE_OK) break;
+                if(storage_virtual_quit(app->fs_api) != FSE_OK) break;
 
 
                 success = true;
                 success = true;
             } while(false);
             } while(false);
-            free(buffer);
 
 
             if(!success) {
             if(!success) {
                 error = storage_file_get_error_desc(app->file);
                 error = storage_file_get_error_desc(app->file);