diff --git a/applications/main/nfc/nfc_i.h b/applications/main/nfc/nfc_i.h index a3a62972c..339db66c7 100644 --- a/applications/main/nfc/nfc_i.h +++ b/applications/main/nfc/nfc_i.h @@ -45,7 +45,6 @@ ARRAY_DEF(MfClassicUserKeys, char*, M_PTR_OPLIST); #define NFC_TEXT_STORE_SIZE 128 -#define NFC_APP_FOLDER ANY_PATH("nfc") typedef enum { NfcRpcStateIdle, diff --git a/applications/main/nfc/scenes/nfc_scene_delete.c b/applications/main/nfc/scenes/nfc_scene_delete.c index 32bd92a07..cbb52bfd0 100644 --- a/applications/main/nfc/scenes/nfc_scene_delete.c +++ b/applications/main/nfc/scenes/nfc_scene_delete.c @@ -52,7 +52,6 @@ void nfc_scene_delete_on_enter(void* context) { bool nfc_scene_delete_on_event(void* context, SceneManagerEvent event) { Nfc* nfc = context; - furi_string_printf(nfc->dev->folder, "%s", NFC_APP_FOLDER); bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { diff --git a/applications/main/nfc/scenes/nfc_scene_file_select.c b/applications/main/nfc/scenes/nfc_scene_file_select.c index 00ccf9012..374a933d1 100644 --- a/applications/main/nfc/scenes/nfc_scene_file_select.c +++ b/applications/main/nfc/scenes/nfc_scene_file_select.c @@ -3,7 +3,6 @@ void nfc_scene_file_select_on_enter(void* context) { Nfc* nfc = context; - furi_string_printf(nfc->dev->folder, "%s", NFC_APP_FOLDER); // Process file_select return nfc_device_set_loading_callback(nfc->dev, nfc_show_loading_popup, nfc); if(!furi_string_size(nfc->dev->load_path)) { diff --git a/applications/main/nfc/scenes/nfc_scene_restore_original_confirm.c b/applications/main/nfc/scenes/nfc_scene_restore_original_confirm.c index 0836c4183..730dd41e8 100644 --- a/applications/main/nfc/scenes/nfc_scene_restore_original_confirm.c +++ b/applications/main/nfc/scenes/nfc_scene_restore_original_confirm.c @@ -24,7 +24,6 @@ void nfc_scene_restore_original_confirm_on_enter(void* context) { bool nfc_scene_restore_original_confirm_on_event(void* context, SceneManagerEvent event) { Nfc* nfc = context; - furi_string_printf(nfc->dev->folder, "%s", NFC_APP_FOLDER); bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { diff --git a/applications/main/nfc/scenes/nfc_scene_save_name.c b/applications/main/nfc/scenes/nfc_scene_save_name.c index b297b2d23..43d476ea7 100644 --- a/applications/main/nfc/scenes/nfc_scene_save_name.c +++ b/applications/main/nfc/scenes/nfc_scene_save_name.c @@ -51,7 +51,6 @@ void nfc_scene_save_name_on_enter(void* context) { bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) { Nfc* nfc = context; - furi_string_printf(nfc->dev->folder, "%s", NFC_APP_FOLDER); bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { diff --git a/applications/plugins/nfc_magic/nfc_magic_i.h b/applications/plugins/nfc_magic/nfc_magic_i.h index a6f9352b4..78f7256ac 100644 --- a/applications/plugins/nfc_magic/nfc_magic_i.h +++ b/applications/plugins/nfc_magic/nfc_magic_i.h @@ -27,8 +27,6 @@ #include #include "NFC_Magic_icons.h" -#define NFC_APP_FOLDER ANY_PATH("nfc") - enum NfcMagicCustomEvent { // Reserve first 100 events for button types and indexes, starting from 0 NfcMagicCustomEventReserved = 100, diff --git a/applications/plugins/nfc_magic/scenes/nfc_magic_scene_file_select.c b/applications/plugins/nfc_magic/scenes/nfc_magic_scene_file_select.c index 825ceacea..a19237ed4 100644 --- a/applications/plugins/nfc_magic/scenes/nfc_magic_scene_file_select.c +++ b/applications/plugins/nfc_magic/scenes/nfc_magic_scene_file_select.c @@ -8,7 +8,6 @@ static bool nfc_magic_scene_file_select_is_file_suitable(NfcDevice* nfc_dev) { void nfc_magic_scene_file_select_on_enter(void* context) { NfcMagic* nfc_magic = context; - furi_string_printf(nfc_magic->nfc_dev->folder, "%s", NFC_APP_FOLDER); // Process file_select return nfc_device_set_loading_callback(nfc_magic->nfc_dev, nfc_magic_show_loading_popup, nfc_magic); diff --git a/fbt_options.py b/fbt_options.py index cfcd50360..5a017d4e8 100644 --- a/fbt_options.py +++ b/fbt_options.py @@ -14,7 +14,7 @@ DEBUG = 0 # Suffix to add to files when building distribution # If OS environment has DIST_SUFFIX set, it will be used instead -DIST_SUFFIX = "CC_CL-0014_12192022" +DIST_SUFFIX = "CC_CL-0015_12192022" # Coprocessor firmware COPRO_OB_DATA = "scripts/ob.data" diff --git a/lib/nfc/nfc_device.c b/lib/nfc/nfc_device.c index 5d266ca4c..343181269 100644 --- a/lib/nfc/nfc_device.c +++ b/lib/nfc/nfc_device.c @@ -27,7 +27,6 @@ NfcDevice* nfc_device_alloc() { nfc_dev->dialogs = furi_record_open(RECORD_DIALOGS); nfc_dev->load_path = furi_string_alloc(); nfc_dev->dev_data.parsed_data = furi_string_alloc(); - nfc_dev->folder = furi_string_alloc(); // Rename cache folder name for backward compatibility if(storage_common_stat(nfc_dev->storage, "/ext/nfc/cache", NULL) == FSE_OK) { @@ -43,7 +42,6 @@ void nfc_device_free(NfcDevice* nfc_dev) { furi_record_close(RECORD_DIALOGS); furi_string_free(nfc_dev->load_path); furi_string_free(nfc_dev->dev_data.parsed_data); - furi_string_free(nfc_dev->folder); free(nfc_dev); } @@ -1330,11 +1328,6 @@ static void nfc_device_get_shadow_path(FuriString* orig_path, FuriString* shadow furi_string_cat_printf(shadow_path, "%s", NFC_APP_SHADOW_EXTENSION); } -static void nfc_device_get_folder_from_path(FuriString* path, FuriString* folder) { - size_t last_slash = furi_string_search_rchar(path, '/'); - furi_string_set_n(folder, path, 0, last_slash); -} - bool nfc_device_save(NfcDevice* dev, const char* dev_name) { furi_assert(dev); @@ -1345,18 +1338,8 @@ bool nfc_device_save(NfcDevice* dev, const char* dev_name) { temp_str = furi_string_alloc(); do { - // Create directory if necessary - FuriString* folder = furi_string_alloc(); - // Get folder from filename (filename is in the form of "folder/filename.nfc", so the folder is "folder/") - furi_string_printf(temp_str, "%s", dev_name); - // Get folder from filename - nfc_device_get_folder_from_path(temp_str, folder); - FURI_LOG_I("Nfc", "Saving to folder %s", furi_string_get_cstr(folder)); - if(!storage_simply_mkdir(dev->storage, furi_string_get_cstr(folder))) { - FURI_LOG_E("Nfc", "Failed to create folder %s", furi_string_get_cstr(folder)); - break; - } - furi_string_free(folder); + // Create nfc directory if necessary + if(!storage_simply_mkdir(dev->storage, NFC_APP_FOLDER)) break; // First remove nfc device file if it was saved furi_string_printf(temp_str, "%s", dev_name); // Open file @@ -1537,9 +1520,10 @@ bool nfc_device_load(NfcDevice* dev, const char* file_path, bool show_dialog) { bool nfc_file_select(NfcDevice* dev) { furi_assert(dev); - const char* folder = furi_string_get_cstr(dev->folder); // Input events and views are managed by file_browser + FuriString* nfc_app_folder; + nfc_app_folder = furi_string_alloc_set(NFC_APP_FOLDER); const DialogsFileBrowserOptions browser_options = { .extension = NFC_APP_EXTENSION, @@ -1549,12 +1533,13 @@ bool nfc_file_select(NfcDevice* dev) { .hide_ext = true, .item_loader_callback = NULL, .item_loader_context = NULL, - .base_path = folder, + .base_path = NFC_APP_FOLDER, }; bool res = dialog_file_browser_show(dev->dialogs, dev->load_path, dev->load_path, &browser_options); + furi_string_free(nfc_app_folder); if(res) { FuriString* filename; filename = furi_string_alloc(); @@ -1607,11 +1592,7 @@ bool nfc_device_delete(NfcDevice* dev, bool use_load_path) { furi_string_set(file_path, dev->load_path); } else { furi_string_printf( - file_path, - "%s/%s%s", - furi_string_get_cstr(dev->folder), - dev->dev_name, - NFC_APP_EXTENSION); + file_path, "%s/%s%s", NFC_APP_FOLDER, dev->dev_name, NFC_APP_EXTENSION); } if(!storage_simply_remove(dev->storage, furi_string_get_cstr(file_path))) break; // Delete shadow file if it exists @@ -1620,11 +1601,7 @@ bool nfc_device_delete(NfcDevice* dev, bool use_load_path) { nfc_device_get_shadow_path(dev->load_path, file_path); } else { furi_string_printf( - file_path, - "%s/%s%s", - furi_string_get_cstr(dev->folder), - dev->dev_name, - NFC_APP_SHADOW_EXTENSION); + file_path, "%s/%s%s", NFC_APP_FOLDER, dev->dev_name, NFC_APP_SHADOW_EXTENSION); } if(!storage_simply_remove(dev->storage, furi_string_get_cstr(file_path))) break; } @@ -1660,12 +1637,7 @@ bool nfc_device_restore(NfcDevice* dev, bool use_load_path) { if(use_load_path && !furi_string_empty(dev->load_path)) { furi_string_set(path, dev->load_path); } else { - furi_string_printf( - path, - "%s/%s%s", - furi_string_get_cstr(dev->folder), - dev->dev_name, - NFC_APP_EXTENSION); + furi_string_printf(path, "%s/%s%s", NFC_APP_FOLDER, dev->dev_name, NFC_APP_EXTENSION); } if(!nfc_device_load_data(dev, path, true)) break; restored = true; diff --git a/lib/nfc/nfc_device.h b/lib/nfc/nfc_device.h index c1f95f5b8..5ad6c4761 100644 --- a/lib/nfc/nfc_device.h +++ b/lib/nfc/nfc_device.h @@ -22,6 +22,7 @@ extern "C" { #define NFC_READER_DATA_MAX_SIZE 64 #define NFC_DICT_KEY_BATCH_SIZE 50 +#define NFC_APP_FOLDER ANY_PATH("nfc") #define NFC_APP_EXTENSION ".nfc" #define NFC_APP_SHADOW_EXTENSION ".shd" @@ -90,7 +91,6 @@ typedef struct { NfcDeviceData dev_data; char dev_name[NFC_DEV_NAME_MAX_LEN + 1]; FuriString* load_path; - FuriString* folder; NfcDeviceSaveFormat format; bool shadow_file_exist;