@@ -93,37 +93,19 @@ static bool scene_action_settings_import_file_browser_callback(
93
93
94
94
// Ask user for file to import from elsewhere on the SD card
95
95
FuriString * 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
-
104
96
// Setup our file browser options
105
97
DialogsFileBrowserOptions fb_options ;
106
98
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 ;
108
100
fb_options .skip_assets = true;
109
101
furi_string_set_str (app -> temp_str , fb_options .base_path );
110
102
fb_options .item_loader_callback = scene_action_settings_import_file_browser_callback ;
111
103
fb_options .item_loader_context = app ;
112
104
113
105
FuriString * full_path = NULL ;
114
106
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 );
125
108
}
126
- furi_string_free (current_path );
127
109
return full_path ;
128
110
}
129
111
@@ -241,8 +223,8 @@ bool scene_action_settings_on_event(void* context, SceneManagerEvent event) {
241
223
consumed = true;
242
224
// get the filename to import
243
225
FuriString * import_file = scene_action_get_file_to_import_alloc (app );
244
- FURI_LOG_I (TAG , "Importing %s" , furi_string_get_cstr (import_file ));
245
226
if (import_file ) {
227
+ FURI_LOG_I (TAG , "Importing %s" , furi_string_get_cstr (import_file ));
246
228
// if it's a .ir file, switch to a scene that lets user pick the command from the file
247
229
// only if there's more than one command in the file. then copy that relevant chunk
248
230
// to the local directory
@@ -274,12 +256,23 @@ bool scene_action_settings_on_event(void* context, SceneManagerEvent event) {
274
256
furi_string_get_cstr (file_name ));
275
257
// FURI_LOG_I(TAG, "New path is %s", furi_string_get_cstr(full_path));
276
258
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 ));
277
264
FS_Error fs_result = storage_common_copy (
278
265
app -> storage ,
279
266
furi_string_get_cstr (import_file ),
280
267
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 );
283
276
}
284
277
furi_string_free (file_name );
285
278
furi_string_free (full_path );
0 commit comments