mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 09:28:36 -07:00
Improve error handling, use correct drive id
This commit is contained in:
@@ -158,7 +158,7 @@ size_t storage_open_files_count(StorageData* storage) {
|
||||
}
|
||||
|
||||
const char* storage_file_get_path(File* file, StorageData* storage) {
|
||||
if(!storage_has_file(file, storage)) return "";
|
||||
StorageFile* storage_file_ref = storage_get_file(file, storage);
|
||||
if(!storage_file_ref) return "";
|
||||
return furi_string_get_cstr(storage_file_ref->path);
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <furi_hal.h>
|
||||
#include "sd_notify.h"
|
||||
#include <furi_hal_sd.h>
|
||||
#include <toolbox/path.h>
|
||||
|
||||
typedef FIL SDFile;
|
||||
typedef DIR SDDir;
|
||||
@@ -740,15 +741,22 @@ FS_Error storage_process_virtual_format(StorageData* storage) {
|
||||
SDData* sd_data = storage->data;
|
||||
uint8_t* work = malloc(_MAX_SS);
|
||||
SDError error = f_mkfs(sd_data->path, FM_ANY, 0, work, _MAX_SS);
|
||||
storage_process_virtual_mount(storage);
|
||||
const char* path = storage_file_get_path(mnt_image, mnt_image_storage);
|
||||
const char* name = basename(path);
|
||||
char label[strlen(name) - 3];
|
||||
strlcpy(label, name, sizeof(label));
|
||||
f_setlabel(label);
|
||||
storage_process_virtual_unmount(storage);
|
||||
free(work);
|
||||
if(error != FR_OK) return FSE_INTERNAL;
|
||||
|
||||
if(storage_process_virtual_mount(storage) == FSE_OK) {
|
||||
// Image file path
|
||||
const char* img_path = storage_file_get_path(mnt_image, mnt_image_storage);
|
||||
// Image file name
|
||||
FuriString* img_name = furi_string_alloc();
|
||||
path_extract_filename_no_ext(img_path, img_name);
|
||||
// Label with drive id prefix
|
||||
char* label = storage_ext_drive_path(storage, furi_string_get_cstr(img_name));
|
||||
furi_string_free(img_name);
|
||||
f_setlabel(label);
|
||||
free(label);
|
||||
storage_process_virtual_unmount(storage);
|
||||
}
|
||||
return FSE_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user