mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-26 03:39:58 -07:00
Merge remote-tracking branch 'ofw/dev' into mntm-dev
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include <m-list.h>
|
||||
#include <m-dict.h>
|
||||
|
||||
#define TAG "Storage"
|
||||
|
||||
#define STORAGE_PATH_PREFIX_LEN 4u
|
||||
_Static_assert(
|
||||
sizeof(STORAGE_ANY_PATH_PREFIX) == STORAGE_PATH_PREFIX_LEN + 1,
|
||||
@@ -62,33 +64,25 @@ static StorageType storage_get_type_by_path(FuriString* path) {
|
||||
|
||||
return type;
|
||||
}
|
||||
static void storage_path_change_to_real_storage(FuriString* path, StorageType real_storage) {
|
||||
if(furi_string_search(path, STORAGE_ANY_PATH_PREFIX) == 0) {
|
||||
switch(real_storage) {
|
||||
case ST_EXT:
|
||||
furi_string_replace_at(
|
||||
path, 0, strlen(STORAGE_EXT_PATH_PREFIX), STORAGE_EXT_PATH_PREFIX);
|
||||
break;
|
||||
case ST_INT:
|
||||
furi_string_replace_at(
|
||||
path, 0, strlen(STORAGE_INT_PATH_PREFIX), STORAGE_INT_PATH_PREFIX);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FS_Error storage_get_data(Storage* app, FuriString* path, StorageData** storage) {
|
||||
StorageType type = storage_get_type_by_path(path);
|
||||
|
||||
if(storage_type_is_valid(type)) {
|
||||
// Any storage phase-out: redirect "/any" to "/ext"
|
||||
if(type == ST_ANY) {
|
||||
type = ST_INT;
|
||||
if(storage_data_status(&app->storage[ST_EXT]) == StorageStatusOK) {
|
||||
type = ST_EXT;
|
||||
}
|
||||
storage_path_change_to_real_storage(path, type);
|
||||
FURI_LOG_W(
|
||||
TAG,
|
||||
STORAGE_ANY_PATH_PREFIX " is deprecated, use " STORAGE_EXT_PATH_PREFIX " instead");
|
||||
furi_string_replace_at(
|
||||
path, 0, strlen(STORAGE_EXT_PATH_PREFIX), STORAGE_EXT_PATH_PREFIX);
|
||||
type = ST_EXT;
|
||||
}
|
||||
|
||||
furi_assert(type == ST_EXT || type == ST_MNT);
|
||||
|
||||
if(storage_data_status(&app->storage[type]) != StorageStatusOK) {
|
||||
return FSE_NOT_READY;
|
||||
}
|
||||
|
||||
*storage = &app->storage[type];
|
||||
@@ -607,6 +601,16 @@ void storage_process_alias(
|
||||
furi_string_get_cstr(apps_assets_path_with_appsid));
|
||||
|
||||
furi_string_free(apps_assets_path_with_appsid);
|
||||
|
||||
} else if(furi_string_start_with(path, STORAGE_INT_PATH_PREFIX)) {
|
||||
furi_string_replace_at(
|
||||
path, 0, strlen(STORAGE_INT_PATH_PREFIX), STORAGE_EXT_PATH_PREFIX "/.int");
|
||||
|
||||
FuriString* int_on_ext_path = furi_string_alloc_set(STORAGE_EXT_PATH_PREFIX "/.int");
|
||||
if(storage_process_common_stat(app, int_on_ext_path, NULL) != FSE_OK) {
|
||||
storage_process_common_mkdir(app, int_on_ext_path);
|
||||
}
|
||||
furi_string_free(int_on_ext_path);
|
||||
} else if(furi_string_start_with(path, STORAGE_CFG_PATH_PREFIX)) {
|
||||
// Create config folder if it doesn't exist
|
||||
FuriString* config_path = furi_string_alloc_set(STORAGE_CFG_PATH_PREFIX);
|
||||
|
||||
Reference in New Issue
Block a user