mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge pull request #80 from jetblk/mass_storage_enhancement
Storage: USB Mass Storage enhancement for setting volume label
This commit is contained in:
@@ -43,10 +43,12 @@ Storage* storage_app_alloc(void) {
|
||||
}
|
||||
|
||||
#ifndef FURI_RAM_EXEC
|
||||
storage_mnt_init(&app->storage[ST_MNT]);
|
||||
storage_int_init(&app->storage[ST_INT]);
|
||||
#endif
|
||||
storage_ext_init(&app->storage[ST_EXT]);
|
||||
#ifndef FURI_RAM_EXEC
|
||||
storage_mnt_init(&app->storage[ST_MNT]);
|
||||
#endif
|
||||
|
||||
// sd icon gui
|
||||
app->sd_gui.enabled = false;
|
||||
|
||||
@@ -156,3 +156,9 @@ size_t storage_open_files_count(StorageData* storage) {
|
||||
size_t count = StorageFileList_size(storage->files);
|
||||
return count;
|
||||
}
|
||||
|
||||
const char* storage_file_get_path(File* file, StorageData* storage) {
|
||||
StorageFile* storage_file_ref = storage_get_file(file, storage);
|
||||
if(!storage_file_ref) return "";
|
||||
return furi_string_get_cstr(storage_file_ref->path);
|
||||
}
|
||||
@@ -35,6 +35,7 @@ void storage_file_init(StorageFile* obj);
|
||||
void storage_file_init_set(StorageFile* obj, const StorageFile* src);
|
||||
void storage_file_set(StorageFile* obj, const StorageFile* src);
|
||||
void storage_file_clear(StorageFile* obj);
|
||||
const char* storage_file_get_path(File* file, StorageData* storage);
|
||||
|
||||
void storage_data_init(StorageData* storage);
|
||||
StorageStatus storage_data_status(StorageData* storage);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <furi_hal.h>
|
||||
#include "sd_notify.h"
|
||||
#include <furi_hal_sd.h>
|
||||
#include <toolbox/path.h>
|
||||
|
||||
typedef FIL SDFile;
|
||||
typedef DIR SDDir;
|
||||
@@ -741,6 +742,20 @@ FS_Error storage_process_virtual_format(StorageData* storage) {
|
||||
SDError error = f_mkfs(sd_data->path, FM_ANY, 0, work, _MAX_SS);
|
||||
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