[FL-3055] Getter for application data path (#2181)
* Threads: application id * Unit tests: appsdata getter test * Unit tests: moar test cases for appsdata getter * Unit tests: remove folders after test * Storage: dir_is_exist, migrate, + unit_tests * Plugins: migration * Storage: common_exists, moar unit_tests 4 "common_migrate", "common_migrate" and "common_merge" bugfixes * Storage: use FuriString for path handling * Storage API: send caller thread id with path * Storage: remove StorageType field in storage file list * Storage: simplify processing * Storage API: send caller thread id with path everywhere * Storage: /app alias, unit tests and path creation * Storage, path helper: remove unused * Examples: app data example * App plugins: use new VFS path * Storage: file_info_is_dir * Services: handle alias if the service accepts a path. * App plugins: fixes * Make PVS happy * Storage: fix storage_merge_recursive * Storage: rename process_aliases to resolve_path. Rename APPS_DATA to APP_DATA. * Apps: use predefined macro instead of raw paths. Example Apps Data: README fixes. * Storage: rename storage_common_resolve_path to storage_common_resolve_path_and_ensure_app_directory * Api: fix version * Storage: rename alias message * Storage: do not create app folders in path resolving process in certain cases. --------- Co-authored-by: Astra <93453568+Astrrra@users.noreply.github.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -60,7 +60,7 @@ bool spi_mem_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneChipDetect);
|
||||
success = true;
|
||||
} else if(event.event == SPIMemSceneStartSubmenuIndexSaved) {
|
||||
furi_string_set(app->file_path, SPI_MEM_FILE_FOLDER);
|
||||
furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX);
|
||||
scene_manager_next_scene(app->scene_manager, SPIMemSceneSelectFile);
|
||||
success = true;
|
||||
} else if(event.event == SPIMemSceneStartSubmenuIndexErase) {
|
||||
|
@@ -16,9 +16,9 @@ static bool spi_mem_back_event_callback(void* context) {
|
||||
}
|
||||
|
||||
SPIMemApp* spi_mem_alloc(void) {
|
||||
SPIMemApp* instance = malloc(sizeof(SPIMemApp));
|
||||
SPIMemApp* instance = malloc(sizeof(SPIMemApp)); //-V799
|
||||
|
||||
instance->file_path = furi_string_alloc();
|
||||
instance->file_path = furi_string_alloc_set(STORAGE_APP_DATA_PATH_PREFIX);
|
||||
instance->gui = furi_record_open(RECORD_GUI);
|
||||
instance->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
instance->view_dispatcher = view_dispatcher_alloc();
|
||||
@@ -37,7 +37,8 @@ SPIMemApp* spi_mem_alloc(void) {
|
||||
instance->text_input = text_input_alloc();
|
||||
instance->mode = SPIMemModeUnknown;
|
||||
|
||||
furi_string_set(instance->file_path, SPI_MEM_FILE_FOLDER);
|
||||
// Migrate data from old sd-card folder
|
||||
storage_common_migrate(instance->storage, EXT_PATH("spimem"), STORAGE_APP_DATA_PATH_PREFIX);
|
||||
|
||||
view_dispatcher_enable_queue(instance->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(instance->view_dispatcher, instance);
|
||||
@@ -70,7 +71,7 @@ SPIMemApp* spi_mem_alloc(void) {
|
||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_external);
|
||||
scene_manager_next_scene(instance->scene_manager, SPIMemSceneStart);
|
||||
return instance;
|
||||
}
|
||||
} //-V773
|
||||
|
||||
void spi_mem_free(SPIMemApp* instance) {
|
||||
view_dispatcher_remove_view(instance->view_dispatcher, SPIMemViewSubmenu);
|
||||
@@ -105,7 +106,6 @@ void spi_mem_free(SPIMemApp* instance) {
|
||||
int32_t spi_mem_app(void* p) {
|
||||
UNUSED(p);
|
||||
SPIMemApp* instance = spi_mem_alloc();
|
||||
spi_mem_file_create_folder(instance);
|
||||
view_dispatcher_run(instance->view_dispatcher);
|
||||
spi_mem_free(instance);
|
||||
return 0;
|
||||
|
@@ -24,7 +24,6 @@
|
||||
|
||||
#define TAG "SPIMem"
|
||||
#define SPI_MEM_FILE_EXTENSION ".bin"
|
||||
#define SPI_MEM_FILE_FOLDER EXT_PATH("spimem")
|
||||
#define SPI_MEM_FILE_NAME_SIZE 100
|
||||
#define SPI_MEM_TEXT_BUFFER_SIZE 128
|
||||
|
||||
|
@@ -1,11 +1,5 @@
|
||||
#include "spi_mem_app_i.h"
|
||||
|
||||
void spi_mem_file_create_folder(SPIMemApp* app) {
|
||||
if(!storage_simply_mkdir(app->storage, SPI_MEM_FILE_FOLDER)) {
|
||||
dialog_message_show_storage_error(app->dialogs, "Cannot create\napp folder");
|
||||
}
|
||||
}
|
||||
|
||||
bool spi_mem_file_delete(SPIMemApp* app) {
|
||||
return (storage_simply_remove(app->storage, furi_string_get_cstr(app->file_path)));
|
||||
}
|
||||
@@ -13,7 +7,7 @@ bool spi_mem_file_delete(SPIMemApp* app) {
|
||||
bool spi_mem_file_select(SPIMemApp* app) {
|
||||
DialogsFileBrowserOptions browser_options;
|
||||
dialog_file_browser_set_basic_options(&browser_options, SPI_MEM_FILE_EXTENSION, &I_Dip8_10px);
|
||||
browser_options.base_path = SPI_MEM_FILE_FOLDER;
|
||||
browser_options.base_path = STORAGE_APP_DATA_PATH_PREFIX;
|
||||
bool success =
|
||||
dialog_file_browser_show(app->dialogs, app->file_path, app->file_path, &browser_options);
|
||||
return success;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include "spi_mem_app.h"
|
||||
|
||||
void spi_mem_file_create_folder(SPIMemApp* app);
|
||||
bool spi_mem_file_select(SPIMemApp* app);
|
||||
bool spi_mem_file_create(SPIMemApp* app, const char* file_name);
|
||||
bool spi_mem_file_delete(SPIMemApp* app);
|
||||
|
Reference in New Issue
Block a user