avr_isp_app_i.c 1013 B

12345678910111213141516171819202122232425262728293031
  1. #include "avr_isp_app_i.h"
  2. #include <lib/toolbox/path.h>
  3. #include <flipper_format/flipper_format_i.h>
  4. #define TAG "AvrIsp"
  5. bool avr_isp_load_from_file(AvrIspApp* app) {
  6. furi_assert(app);
  7. FuriString* file_path = furi_string_alloc();
  8. FuriString* file_name = furi_string_alloc();
  9. DialogsFileBrowserOptions browser_options;
  10. dialog_file_browser_set_basic_options(
  11. &browser_options, AVR_ISP_APP_EXTENSION, &I_avr_app_icon_10x10);
  12. browser_options.base_path = STORAGE_APP_DATA_PATH_PREFIX;
  13. // Input events and views are managed by file_select
  14. bool res = dialog_file_browser_show(app->dialogs, file_path, app->file_path, &browser_options);
  15. if(res) {
  16. path_extract_dirname(furi_string_get_cstr(file_path), app->file_path);
  17. path_extract_filename(file_path, file_name, true);
  18. strncpy(app->file_name_tmp, furi_string_get_cstr(file_name), AVR_ISP_MAX_LEN_NAME);
  19. }
  20. furi_string_free(file_name);
  21. furi_string_free(file_path);
  22. return res;
  23. }