@@ -93,37 +93,19 @@ static bool scene_action_settings_import_file_browser_callback(
9393
9494// Ask user for file to import from elsewhere on the SD card
9595FuriString * scene_action_get_file_to_import_alloc (App * app ) {
96- FuriString * current_path = furi_string_alloc ();
97- if (app -> selected_item != EMPTY_ACTION_INDEX ) {
98- Item * item = ItemArray_get (app -> items_view -> items , app -> selected_item );
99- path_extract_dirname (furi_string_get_cstr (item -> path ), current_path );
100- } else {
101- furi_string_set (current_path , app -> items_view -> path );
102- }
103-
10496 // Setup our file browser options
10597 DialogsFileBrowserOptions fb_options ;
10698 dialog_file_browser_set_basic_options (& fb_options , "" , NULL );
107- fb_options .base_path = furi_string_get_cstr ( current_path ) ;
99+ fb_options .base_path = STORAGE_EXT_PATH_PREFIX ;
108100 fb_options .skip_assets = true;
109101 furi_string_set_str (app -> temp_str , fb_options .base_path );
110102 fb_options .item_loader_callback = scene_action_settings_import_file_browser_callback ;
111103 fb_options .item_loader_context = app ;
112104
113105 FuriString * full_path = NULL ;
114106 if (dialog_file_browser_show (app -> dialog , app -> temp_str , app -> temp_str , & fb_options )) {
115- // FURI_LOG_I(TAG, "Selected file is %s", furi_string_get_cstr(app->temp_str));
116- FuriString * file_name = furi_string_alloc ();
117- path_extract_filename (app -> temp_str , file_name , false);
118- // FURI_LOG_I(TAG, "Importing file %s", furi_string_get_cstr(file_name));
119- full_path = furi_string_alloc_printf (
120- "%s/%s" , furi_string_get_cstr (current_path ), furi_string_get_cstr (file_name ));
121- // FURI_LOG_I(TAG, "New path is %s", furi_string_get_cstr(full_path));
122- furi_string_free (file_name );
123- } else {
124- // FURI_LOG_I(TAG, "User cancelled");
107+ full_path = furi_string_alloc_set (app -> temp_str );
125108 }
126- furi_string_free (current_path );
127109 return full_path ;
128110}
129111
@@ -241,8 +223,8 @@ bool scene_action_settings_on_event(void* context, SceneManagerEvent event) {
241223 consumed = true;
242224 // get the filename to import
243225 FuriString * import_file = scene_action_get_file_to_import_alloc (app );
244- FURI_LOG_I (TAG , "Importing %s" , furi_string_get_cstr (import_file ));
245226 if (import_file ) {
227+ FURI_LOG_I (TAG , "Importing %s" , furi_string_get_cstr (import_file ));
246228 // if it's a .ir file, switch to a scene that lets user pick the command from the file
247229 // only if there's more than one command in the file. then copy that relevant chunk
248230 // to the local directory
@@ -274,12 +256,23 @@ bool scene_action_settings_on_event(void* context, SceneManagerEvent event) {
274256 furi_string_get_cstr (file_name ));
275257 // FURI_LOG_I(TAG, "New path is %s", furi_string_get_cstr(full_path));
276258
259+ FURI_LOG_I (
260+ TAG ,
261+ "Copy: %s to %s" ,
262+ furi_string_get_cstr (import_file ),
263+ furi_string_get_cstr (full_path ));
277264 FS_Error fs_result = storage_common_copy (
278265 app -> storage ,
279266 furi_string_get_cstr (import_file ),
280267 furi_string_get_cstr (full_path ));
281- if (fs_result == FSE_OK ) {
282- } else {
268+ if (fs_result != FSE_OK ) {
269+ FURI_LOG_E (
270+ TAG , "Copy file failed! %s" , filesystem_api_error_get_desc (fs_result ));
271+ FuriString * error_msg = furi_string_alloc_printf (
272+ "Copy failed!\nError: %s" , filesystem_api_error_get_desc (fs_result ));
273+ dialog_message_show_storage_error (
274+ app -> dialog , furi_string_get_cstr (error_msg ));
275+ furi_string_free (error_msg );
283276 }
284277 furi_string_free (file_name );
285278 furi_string_free (full_path );
0 commit comments