diff --git a/firmware/application/apps/ble_rx_app.cpp b/firmware/application/apps/ble_rx_app.cpp index 1d40ecc15..be03b53b1 100644 --- a/firmware/application/apps/ble_rx_app.cpp +++ b/firmware/application/apps/ble_rx_app.cpp @@ -765,7 +765,7 @@ void BLERxView::on_filter_change(std::string value) { } void BLERxView::on_file_changed(const std::filesystem::path& new_file_path) { - file_path = fs::path(u"/") + new_file_path; + file_path = new_file_path; found_count = 0; total_count = 0; searchList.clear(); diff --git a/firmware/application/apps/ble_tx_app.cpp b/firmware/application/apps/ble_tx_app.cpp index 013e85402..d9680c4d4 100644 --- a/firmware/application/apps/ble_tx_app.cpp +++ b/firmware/application/apps/ble_tx_app.cpp @@ -449,7 +449,7 @@ BLETxView::BLETxView( } void BLETxView::on_file_changed(const fs::path& new_file_path) { - file_path = fs::path(u"/") + new_file_path; + file_path = new_file_path; num_packets = 0; { // Get the size of the data file. diff --git a/firmware/application/apps/replay_app.cpp b/firmware/application/apps/replay_app.cpp index bc7d8b9ff..832b41c6c 100644 --- a/firmware/application/apps/replay_app.cpp +++ b/firmware/application/apps/replay_app.cpp @@ -44,7 +44,7 @@ void ReplayAppView::set_ready() { } void ReplayAppView::on_file_changed(const fs::path& new_file_path) { - file_path = fs::path(u"/") + new_file_path; + file_path = new_file_path; File::Size file_size{}; { // Get the size of the data file. diff --git a/firmware/application/apps/ui_recon.cpp b/firmware/application/apps/ui_recon.cpp index 09c0640c2..afa3782f0 100644 --- a/firmware/application/apps/ui_recon.cpp +++ b/firmware/application/apps/ui_recon.cpp @@ -1460,7 +1460,7 @@ void ReconView::handle_repeat_thread_done(const uint32_t return_code) { stop_repeat(true); } else if (return_code == ReplayThread::READ_ERROR) { stop_repeat(false); - repeat_file_error(u"/" + repeat_rec_path + u"/" + repeat_rec_file, "Can't open file to send."); + repeat_file_error(rawfile, "Can't open file to send."); } } diff --git a/firmware/application/external/gpssim/gps_sim_app.cpp b/firmware/application/external/gpssim/gps_sim_app.cpp index ff5e73f25..2ee41de6a 100644 --- a/firmware/application/external/gpssim/gps_sim_app.cpp +++ b/firmware/application/external/gpssim/gps_sim_app.cpp @@ -28,6 +28,7 @@ #include "io_file.hpp" #include "metadata_file.hpp" #include "utility.hpp" +#include "file_path.hpp" #include "baseband_api.hpp" #include "portapack.hpp" @@ -43,7 +44,7 @@ void GpsSimAppView::set_ready() { } void GpsSimAppView::on_file_changed(const fs::path& new_file_path) { - file_path = fs::path(u"/") + new_file_path; + file_path = new_file_path; File::Size file_size{}; { // Get the size of the data file. @@ -185,6 +186,8 @@ GpsSimAppView::GpsSimAppView( button_open.on_select = [this, &nav](Button&) { auto open_view = nav.push(".C8"); + ensure_directory(gps_dir); + open_view->push_dir(gps_dir); open_view->on_changed = [this](std::filesystem::path new_file_path) { on_file_changed(new_file_path); }; diff --git a/firmware/application/file_path.cpp b/firmware/application/file_path.cpp index 9188d2a5a..a56e141f3 100644 --- a/firmware/application/file_path.cpp +++ b/firmware/application/file_path.cpp @@ -24,6 +24,7 @@ const std::filesystem::path adsb_dir = u"ADSB"; const std::filesystem::path ais_dir = u"AIS"; +const std::filesystem::path apps_dir = u"APPS"; const std::filesystem::path aprs_dir = u"APRS"; const std::filesystem::path audio_dir = u"AUDIO"; const std::filesystem::path blerx_dir = u"BLERX"; @@ -32,11 +33,13 @@ const std::filesystem::path captures_dir = u"CAPTURES"; const std::filesystem::path debug_dir = u"DEBUG"; const std::filesystem::path firmware_dir = u"FIRMWARE"; const std::filesystem::path freqman_dir = u"FREQMAN"; +const std::filesystem::path gps_dir = u"GPS"; const std::filesystem::path logs_dir = u"LOGS"; const std::filesystem::path looking_glass_dir = u"LOOKINGGLASS"; const std::filesystem::path playlist_dir = u"PLAYLIST"; const std::filesystem::path remotes_dir = u"REMOTES"; const std::filesystem::path repeat_rec_path = u"CAPTURES"; +const std::filesystem::path samples_dir = u"SAMPLES"; const std::filesystem::path screenshots_dir = u"SCREENSHOTS"; const std::filesystem::path settings_dir = u"SETTINGS"; const std::filesystem::path spectrum_dir = u"SPECTRUM"; diff --git a/firmware/application/file_path.hpp b/firmware/application/file_path.hpp index 7661ab22a..802ee8686 100644 --- a/firmware/application/file_path.hpp +++ b/firmware/application/file_path.hpp @@ -26,6 +26,7 @@ extern const std::filesystem::path adsb_dir; extern const std::filesystem::path ais_dir; +extern const std::filesystem::path apps_dir; extern const std::filesystem::path aprs_dir; extern const std::filesystem::path audio_dir; extern const std::filesystem::path blerx_dir; @@ -34,11 +35,13 @@ extern const std::filesystem::path captures_dir; extern const std::filesystem::path debug_dir; extern const std::filesystem::path firmware_dir; extern const std::filesystem::path freqman_dir; +extern const std::filesystem::path gps_dir; extern const std::filesystem::path logs_dir; extern const std::filesystem::path looking_glass_dir; extern const std::filesystem::path playlist_dir; extern const std::filesystem::path remotes_dir; extern const std::filesystem::path repeat_rec_path; +extern const std::filesystem::path samples_dir; extern const std::filesystem::path screenshots_dir; extern const std::filesystem::path settings_dir; extern const std::filesystem::path spectrum_dir; diff --git a/firmware/application/ui_external_items_menu_loader.cpp b/firmware/application/ui_external_items_menu_loader.cpp index 98fbe60e8..48cb7ab70 100644 --- a/firmware/application/ui_external_items_menu_loader.cpp +++ b/firmware/application/ui_external_items_menu_loader.cpp @@ -1,6 +1,7 @@ #include "ui_external_items_menu_loader.hpp" #include "sd_card.hpp" +#include "file_path.hpp" namespace ui { @@ -11,8 +12,8 @@ namespace ui { if (!callback) return; if (sd_card::status() != sd_card::Status::Mounted) return; - for (const auto& entry : std::filesystem::directory_iterator(u"APPS", u"*.ppma")) { - auto filePath = u"/APPS/" + entry.path(); + for (const auto& entry : std::filesystem::directory_iterator(apps_dir, u"*.ppma")) { + auto filePath = apps_dir / entry.path(); File app; auto openError = app.open(filePath); @@ -52,8 +53,8 @@ namespace ui { if (sd_card::status() != sd_card::Status::Mounted) return external_apps; - for (const auto& entry : std::filesystem::directory_iterator(u"APPS", u"*.ppma")) { - auto filePath = u"/APPS/" + entry.path(); + for (const auto& entry : std::filesystem::directory_iterator(apps_dir, u"*.ppma")) { + auto filePath = apps_dir / entry.path(); File app; auto openError = app.open(filePath); @@ -86,7 +87,7 @@ namespace ui { gridItem.on_select = [&nav, app_location, filePath]() { if (!run_external_app(nav, filePath)) { - nav.display_modal("Error", "The .ppma file in your APPS\nfolder can't be read. Please\nupdate your SD Card content."); + nav.display_modal("Error", "The .ppma file in your " + apps_dir.string() + "\nfolder can't be read. Please\nupdate your SD Card content."); } }; } else { @@ -95,7 +96,7 @@ namespace ui { gridItem.bitmap = &bitmap_sd_card_error; gridItem.on_select = [&nav]() { - nav.display_modal("Error", "The .ppma file in your APPS\nfolder is outdated. Please\nupdate your SD Card content."); + nav.display_modal("Error", "The .ppma file in your " + apps_dir.string() + "\nfolder is outdated. Please\nupdate your SD Card content."); }; } diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index a8a6f2bcc..a48924385 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -719,6 +719,7 @@ static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc) }; } +// clang-format off void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& grid) { auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav); if (externalItems.empty()) { @@ -730,7 +731,7 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& "Notice", "External app directory empty;\n" "see Mayhem wiki and copy apps\n" - "to APPS folder of SD card."); + "to " + apps_dir.string() + " folder of SD card."); }}); } else { for (auto const& gridItem : externalItems) { @@ -738,6 +739,7 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& } } } +// clang-format on /* ReceiversMenuView *****************************************************/ diff --git a/firmware/application/usb_serial_shell.cpp b/firmware/application/usb_serial_shell.cpp index 6aba0f14d..768f4ff7f 100644 --- a/firmware/application/usb_serial_shell.cpp +++ b/firmware/application/usb_serial_shell.cpp @@ -665,7 +665,7 @@ static void cmd_appstart(BaseSequentialStream* chp, int argc, char* argv[]) { return; } // since ext app loader changed, we can just pass the string to it, and it"ll return if started or not. - std::string appwithpath = "/APPS/"; + std::string appwithpath = "/" + apps_dir.string() + "/"; appwithpath += argv[0]; appwithpath += ".ppma"; bool ret = ui::ExternalItemsMenuLoader::run_external_app(*nav, path_from_string8((char*)appwithpath.c_str()));