fix flash util err when no APPS dir (#2155)

* add path class usage

* fix when don't have apps dir

* clean up
This commit is contained in:
summermorningdream 2024-05-20 15:02:29 +08:00 committed by GitHub
parent 2a78c543a1
commit db3ae29bd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -83,6 +83,7 @@ FlashUtilityView::FlashUtilityView(NavigationView& nav)
menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8}); menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8});
ensure_directory(apps_dir);
ensure_directory(firmware_dir); ensure_directory(firmware_dir);
auto add_firmware_items = [&]( auto add_firmware_items = [&](
@ -154,7 +155,7 @@ bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) {
if (path.empty() || !valid_firmware_file(path.c_str())) { if (path.empty() || !valid_firmware_file(path.c_str())) {
painter.fill_rectangle({0, 50, portapack::display.width(), 90}, ui::Color::black()); painter.fill_rectangle({0, 50, portapack::display.width(), 90}, ui::Color::black());
painter.draw_string({0, 60}, Styles::red, "BAD FIRMWARE FILE"); painter.draw_string({0, 60}, Styles::red, "BAD FIRMWARE FILE OR W/R ERR");
chThdSleepMilliseconds(5000); chThdSleepMilliseconds(5000);
return false; return false;
} }