Declare all folder names in a single source file (#2039)

This commit is contained in:
Mark Thompson 2024-03-25 02:44:49 -05:00 committed by GitHub
parent d9bbd1b9ff
commit d5c8525afc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
56 changed files with 224 additions and 105 deletions

View File

@ -190,6 +190,7 @@ set(CPPSRC
event_m0.cpp event_m0.cpp
file_reader.cpp file_reader.cpp
file.cpp file.cpp
file_path.cpp
freqman_db.cpp freqman_db.cpp
freqman.cpp freqman.cpp
io_convert.cpp io_convert.cpp

View File

@ -30,6 +30,7 @@
#include "portapack.hpp" #include "portapack.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
@ -40,7 +41,7 @@ using namespace portapack;
namespace { namespace {
fs::path get_settings_path(const std::string& app_name) { fs::path get_settings_path(const std::string& app_name) {
return fs::path{SETTINGS_DIR} / app_name + u".ini"; return settings_dir / app_name + u".ini";
} }
} // namespace } // namespace
@ -156,7 +157,7 @@ bool save_settings(std::string_view store_name, const SettingBindings& bindings)
File f; File f;
auto path = get_settings_path(std::string{store_name}); auto path = get_settings_path(std::string{store_name});
ensure_directory(SETTINGS_DIR); ensure_directory(settings_dir);
auto error = f.create(path); auto error = f.create(path);
if (error) if (error)
return false; return false;

View File

@ -36,9 +36,6 @@
#include "max283x.hpp" #include "max283x.hpp"
#include "string_format.hpp" #include "string_format.hpp"
// Folder to store app settings, pmem_fileflag, and date_fileflag
#define SETTINGS_DIR u"/SETTINGS"
// Bring in the string_view literal. // Bring in the string_view literal.
using std::literals::operator""sv; using std::literals::operator""sv;

View File

@ -24,6 +24,7 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
using namespace acars; using namespace acars;
@ -77,7 +78,7 @@ ACARSAppView::ACARSAppView(NavigationView& nav)
logger = std::make_unique<ACARSLogger>(); logger = std::make_unique<ACARSLogger>();
if (logger) if (logger)
logger->append(LOG_ROOT_DIR "/ACARS.TXT"); logger->append(logs_dir / u"ACARS.TXT");
} }
ACARSAppView::~ACARSAppView() { ACARSAppView::~ACARSAppView() {

View File

@ -35,7 +35,7 @@
class ACARSLogger { class ACARSLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }

View File

@ -23,6 +23,7 @@
#include "string_format.hpp" #include "string_format.hpp"
#include "database.hpp" #include "database.hpp"
#include "file_path.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
@ -399,7 +400,7 @@ AISAppView::AISAppView(NavigationView& nav)
logger = std::make_unique<AISLogger>(); logger = std::make_unique<AISLogger>();
if (logger) { if (logger) {
logger->append(LOG_ROOT_DIR "/AIS.TXT"); logger->append(logs_dir / u"AIS.TXT");
} }
} }

View File

@ -32,6 +32,7 @@
#include "string_format.hpp" #include "string_format.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "ui_text.hpp" #include "ui_text.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
using namespace modems; using namespace modems;
@ -100,7 +101,7 @@ BLECommView::BLECommView(NavigationView& nav)
logging = v; logging = v;
if (logger && logging) if (logger && logging)
logger->append(LOG_ROOT_DIR "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT"); logger->append(logs_dir.string() + "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
}; };
options_channel.on_change = [this](size_t, int32_t i) { options_channel.on_change = [this](size_t, int32_t i) {

View File

@ -42,7 +42,7 @@
class BLECommLogger { class BLECommLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }

View File

@ -470,10 +470,7 @@ BLERxView::BLERxView(NavigationView& nav)
logging = v; logging = v;
if (logger && logging) if (logger && logging)
logger->append( logger->append(blerx_dir.string() + "/Logs/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
"BLERX/Logs"
"/BLELOG_" +
to_string_timestamp(rtc_time::now()) + ".TXT");
}; };
check_log.set_value(logging); check_log.set_value(logging);

View File

@ -36,12 +36,13 @@
#include "log_file.hpp" #include "log_file.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "usb_serial_thread.hpp" #include "usb_serial_thread.hpp"
#include "file_path.hpp"
#include "recent_entries.hpp" #include "recent_entries.hpp"
class BLELogger { class BLELogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }
@ -133,7 +134,7 @@ class BleRecentEntryDetailView : public View {
void on_save_file(const std::string value, BLETxPacket packetToSave); void on_save_file(const std::string value, BLETxPacket packetToSave);
bool saveFile(const std::filesystem::path& path, BLETxPacket packetToSave); bool saveFile(const std::filesystem::path& path, BLETxPacket packetToSave);
std::string packetFileBuffer{}; std::string packetFileBuffer{};
std::filesystem::path packet_save_path{u"BLERX/Lists/????.csv"}; std::filesystem::path packet_save_path{blerx_dir / u"Lists/????.csv"};
static constexpr uint8_t total_data_lines{5}; static constexpr uint8_t total_data_lines{5};
@ -250,9 +251,9 @@ class BLERxView : public View {
uint64_t total_count = 0; uint64_t total_count = 0;
std::vector<std::string> searchList{}; std::vector<std::string> searchList{};
std::filesystem::path find_packet_path{u"BLERX/Find/????.TXT"}; std::filesystem::path find_packet_path{blerx_dir / u"Find/????.TXT"};
std::filesystem::path log_packets_path{u"BLERX/Logs/????.TXT"}; std::filesystem::path log_packets_path{blerx_dir / u"Logs/????.TXT"};
std::filesystem::path packet_save_path{u"BLERX/Lists/????.csv"}; std::filesystem::path packet_save_path{blerx_dir / u"Lists/????.csv"};
static constexpr auto header_height = 4 * 16; static constexpr auto header_height = 4 * 16;
static constexpr auto switch_button_height = 3 * 16; static constexpr auto switch_button_height = 3 * 16;

View File

@ -34,6 +34,7 @@
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "rtc_time.hpp" #include "rtc_time.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
using namespace modems; using namespace modems;

View File

@ -36,6 +36,7 @@
#include "replay_thread.hpp" #include "replay_thread.hpp"
#include "log_file.hpp" #include "log_file.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
#include "recent_entries.hpp" #include "recent_entries.hpp"
@ -44,7 +45,7 @@
class BLELoggerTx { class BLELoggerTx {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }
@ -138,7 +139,7 @@ class BLETxView : public View {
uint32_t prev_value{0}; uint32_t prev_value{0};
std::filesystem::path file_path{}; std::filesystem::path file_path{};
std::filesystem::path packet_save_path{u"BLETX/BLETX_????.TXT"}; std::filesystem::path packet_save_path{bletx_dir / u"BLETX_????.TXT"};
uint8_t channel_number = 37; uint8_t channel_number = 37;
bool auto_channel = false; bool auto_channel = false;
@ -165,7 +166,7 @@ class BLETxView : public View {
std::unique_ptr<FileWrapper> dataFileWrapper{}; std::unique_ptr<FileWrapper> dataFileWrapper{};
File dataFile{}; File dataFile{};
std::filesystem::path dataTempFilePath{u"BLETX/dataFileTemp.TXT"}; std::filesystem::path dataTempFilePath{bletx_dir / u"dataFileTemp.TXT"};
std::vector<uint16_t> markedBytes{}; std::vector<uint16_t> markedBytes{};
CursorPos cursor_pos{}; CursorPos cursor_pos{};
uint8_t marked_counter = 0; uint8_t marked_counter = 0;

View File

@ -31,6 +31,7 @@
#include "ui_spectrum.hpp" #include "ui_spectrum.hpp"
#include "app_settings.hpp" #include "app_settings.hpp"
#include "radio_state.hpp" #include "radio_state.hpp"
#include "file_path.hpp"
namespace ui { namespace ui {
@ -101,7 +102,7 @@ class CaptureAppView : public View {
RecordView record_view{ RecordView record_view{
{0 * 8, 2 * 16, 30 * 8, 1 * 16}, {0 * 8, 2 * 16, 30 * 8, 1 * 16},
u"BBD_????.*", u"BBD_????.*",
u"CAPTURES", captures_dir,
RecordView::FileType::RawS16, RecordView::FileType::RawS16,
16384, 16384,
3}; 3};

View File

@ -31,6 +31,7 @@ using namespace portapack;
#include "crc.hpp" #include "crc.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "file_path.hpp"
namespace ert { namespace ert {
@ -129,7 +130,7 @@ ERTAppView::ERTAppView(NavigationView& nav)
logger = std::make_unique<ERTLogger>(); logger = std::make_unique<ERTLogger>();
if (logger) { if (logger) {
logger->append(LOG_ROOT_DIR "/ERT.TXT"); logger->append(logs_dir / u"ERT.TXT");
} }
} }

View File

@ -27,6 +27,7 @@
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
using namespace pocsag; using namespace pocsag;
@ -115,7 +116,7 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
: FILTER_DROP; : FILTER_DROP;
} }
logger.append(LOG_ROOT_DIR "/POCSAG.TXT"); logger.append(logs_dir / u"POCSAG.TXT");
field_squelch.set_value(receiver_model.squelch_level()); field_squelch.set_value(receiver_model.squelch_level());
field_squelch.on_change = [this](int32_t v) { field_squelch.on_change = [this](int32_t v) {

View File

@ -39,7 +39,7 @@
class POCSAGLogger { class POCSAGLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }

View File

@ -28,6 +28,7 @@
#include "tonesets.hpp" #include "tonesets.hpp"
#include "ui_tone_key.hpp" #include "ui_tone_key.hpp"
#include "audio.hpp" #include "audio.hpp"
#include "file_path.hpp"
using namespace tonekey; using namespace tonekey;
using namespace portapack; using namespace portapack;
@ -164,7 +165,7 @@ void SoundBoardView::refresh_list() {
// List directories and files, put directories up top // List directories and files, put directories up top
uint32_t count = 0; uint32_t count = 0;
for (const auto& entry : std::filesystem::directory_iterator(u"WAV", u"*")) { for (const auto& entry : std::filesystem::directory_iterator(wav_dir, u"*")) {
if (std::filesystem::is_regular_file(entry.status())) { if (std::filesystem::is_regular_file(entry.status())) {
if (entry.path().string().length()) { if (entry.path().string().length()) {
auto entry_extension = entry.path().extension().string(); auto entry_extension = entry.path().extension().string();
@ -173,7 +174,7 @@ void SoundBoardView::refresh_list() {
c = toupper(c); c = toupper(c);
if (entry_extension == ".WAV") { if (entry_extension == ".WAV") {
if (reader->open(u"/WAV/" + entry.path().native())) { if (reader->open(wav_dir / entry.path())) {
if ((reader->channels() == 1) && ((reader->bits_per_sample() == 8) || (reader->bits_per_sample() == 16))) { if ((reader->channels() == 1) && ((reader->bits_per_sample() == 8) || (reader->bits_per_sample() == 16))) {
// sounds[c].ms_duration = reader->ms_duration(); // sounds[c].ms_duration = reader->ms_duration();
// sounds[c].path = u"WAV/" + entry.path().native(); // sounds[c].path = u"WAV/" + entry.path().native();

View File

@ -30,6 +30,7 @@ using namespace portapack;
#include "string_format.hpp" #include "string_format.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
namespace tpms { namespace tpms {
@ -176,7 +177,7 @@ TPMSAppView::TPMSAppView(NavigationView&) {
logger = std::make_unique<TPMSLogger>(); logger = std::make_unique<TPMSLogger>();
if (logger) { if (logger) {
logger->append(LOG_ROOT_DIR "/TPMS.TXT"); logger->append(logs_dir / u"TPMS.TXT");
} }
} }

View File

@ -31,6 +31,7 @@
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "rtc_time.hpp" #include "rtc_time.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
@ -390,7 +391,7 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
}; };
logger = std::make_unique<ADSBLogger>(); logger = std::make_unique<ADSBLogger>();
logger->append(LOG_ROOT_DIR "/ADSB.TXT"); logger->append(logs_dir / u"ADSB.TXT");
receiver_model.enable(); receiver_model.enable();
baseband::set_adsb(); baseband::set_adsb();

View File

@ -27,6 +27,7 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
@ -111,7 +112,7 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect)
logger = std::make_unique<APRSLogger>(); logger = std::make_unique<APRSLogger>();
if (logger) if (logger)
logger->append(LOG_ROOT_DIR "/APRS.TXT"); logger->append(logs_dir / u"APRS.TXT");
baseband::set_aprs(1200); baseband::set_aprs(1200);

View File

@ -36,10 +36,11 @@
#include "log_file.hpp" #include "log_file.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
class APRSLogger { class APRSLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }
@ -232,7 +233,7 @@ class APRSRxView : public View {
RecordView record_view{ RecordView record_view{
{0 * 8, 1 * 16, 30 * 8, 1 * 16}, {0 * 8, 1 * 16, 30 * 8, 1 * 16},
u"AFS_????.WAV", u"AFS_????.WAV",
u"APRS", aprs_dir,
RecordView::FileType::WAV, RecordView::FileType::WAV,
4096, 4096,
4}; 4};

View File

@ -23,11 +23,10 @@
#include "ui_flash_utility.hpp" #include "ui_flash_utility.hpp"
#include "ui_styles.hpp" #include "ui_styles.hpp"
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
#include "file_path.hpp"
namespace ui { namespace ui {
static const std::filesystem::path firmware_path = u"/FIRMWARE";
// Firmware image validation // Firmware image validation
static const char* hackrf_magic = "HACKRFFW"; static const char* hackrf_magic = "HACKRFFW";
#define FIRMWARE_INFO_AREA_OFFSET 0x400 #define FIRMWARE_INFO_AREA_OFFSET 0x400
@ -84,7 +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(firmware_path); ensure_directory(firmware_dir);
auto add_firmware_items = [&]( auto add_firmware_items = [&](
const std::filesystem::path& folder_path, const std::filesystem::path& folder_path,
@ -103,8 +102,8 @@ FlashUtilityView::FlashUtilityView(NavigationView& nav)
} }
}; };
add_firmware_items(firmware_path, u"*.bin", ui::Color::red()); add_firmware_items(firmware_dir, u"*.bin", ui::Color::red());
add_firmware_items(firmware_path, u"*.tar", ui::Color::purple()); add_firmware_items(firmware_dir, u"*.tar", ui::Color::purple());
// add_firmware_items(user_firmware_folder,u"*.bin", ui::Color::purple()); // add_firmware_items(user_firmware_folder,u"*.bin", ui::Color::purple());
} }
@ -116,7 +115,7 @@ void FlashUtilityView::firmware_selected(std::filesystem::path::string_type path
YESNO, YESNO,
[this, path](bool choice) { [this, path](bool choice) {
if (choice) { if (choice) {
std::u16string full_path = std::u16string(u"FIRMWARE/") + path; std::filesystem::path::string_type full_path = firmware_dir.native() + u"/" + path;
this->flash_firmware(full_path); this->flash_firmware(full_path);
} }
}); });

View File

@ -31,6 +31,7 @@
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "ui_styles.hpp" #include "ui_styles.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
#include <memory> #include <memory>

View File

@ -27,6 +27,7 @@
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
#include "ui_freqman.hpp" #include "ui_freqman.hpp"
@ -134,7 +135,7 @@ FskxRxMainView::FskxRxMainView(NavigationView& nav)
field_frequency.set_value(initial_target_frequency); field_frequency.set_value(initial_target_frequency);
deviation_frequency.set_value(initial_deviation); deviation_frequency.set_value(initial_deviation);
logger.append(LOG_ROOT_DIR "/FSKRX.TXT"); logger.append(logs_dir / u"FSKRX.TXT");
baseband::set_fsk(initial_deviation); baseband::set_fsk(initial_deviation);

View File

@ -42,7 +42,7 @@
class FskRxLogger { class FskRxLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }

View File

@ -25,6 +25,7 @@
#include "complex.hpp" #include "complex.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "ui_fileman.hpp" #include "ui_fileman.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -47,7 +48,7 @@ IQTrimView::IQTrimView(NavigationView& nav)
field_path.on_select = [this](TextField&) { field_path.on_select = [this](TextField&) {
auto open_view = nav_.push<FileLoadView>(".C*"); auto open_view = nav_.push<FileLoadView>(".C*");
open_view->push_dir(u"CAPTURES"); open_view->push_dir(captures_dir);
open_view->on_changed = [this](fs::path path) { open_view->on_changed = [this](fs::path path) {
open_file(path); open_file(path);
}; };

View File

@ -26,6 +26,7 @@
#include "file_reader.hpp" #include "file_reader.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "audio.hpp" #include "audio.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
@ -571,7 +572,7 @@ void GlassView::set_spec_iq_phase_calibration_value(uint8_t cal_value) { // def
void GlassView::load_presets() { void GlassView::load_presets() {
File presets_file; File presets_file;
auto error = presets_file.open("LOOKINGGLASS/PRESETS.TXT"); auto error = presets_file.open(looking_glass_dir / u"PRESETS.TXT");
presets_db.clear(); presets_db.clear();
// Add the "Manual" entry. // Add the "Manual" entry.

View File

@ -36,6 +36,7 @@
#include "string_format.hpp" #include "string_format.hpp"
#include "ui_fileman.hpp" #include "ui_fileman.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
#include <unistd.h> #include <unistd.h>
#include <fstream> #include <fstream>
@ -130,7 +131,7 @@ void PlaylistView::open_file(bool prompt_save) {
} }
auto open_view = nav_.push<FileLoadView>(".PPL"); auto open_view = nav_.push<FileLoadView>(".PPL");
open_view->push_dir(u"PLAYLIST"); open_view->push_dir(playlist_dir);
open_view->on_changed = [this](fs::path new_file_path) { open_view->on_changed = [this](fs::path new_file_path) {
on_file_changed(new_file_path); on_file_changed(new_file_path);
}; };
@ -169,7 +170,7 @@ void PlaylistView::save_file(bool show_dialogs) {
void PlaylistView::add_entry(fs::path&& path) { void PlaylistView::add_entry(fs::path&& path) {
if (playlist_path_.empty()) { if (playlist_path_.empty()) {
playlist_path_ = next_filename_matching_pattern(u"/PLAYLIST/PLAY_????.PPL"); playlist_path_ = next_filename_matching_pattern(playlist_dir / u"PLAY_????.PPL");
// Hack around focus getting called by ctor before parent is set. // Hack around focus getting called by ctor before parent is set.
if (parent()) if (parent())
@ -387,7 +388,7 @@ PlaylistView::PlaylistView(
&waterfall, &waterfall,
}); });
ensure_directory(u"PLAYLIST"); ensure_directory(playlist_dir);
waterfall.show_audio_spectrum_view(false); waterfall.show_audio_spectrum_view(false);
field_frequency.set_value(transmitter_model.target_frequency()); field_frequency.set_value(transmitter_model.target_frequency());
@ -410,7 +411,7 @@ PlaylistView::PlaylistView(
if (is_active()) if (is_active())
return; return;
auto open_view = nav_.push<FileLoadView>(".C*"); auto open_view = nav_.push<FileLoadView>(".C*");
open_view->push_dir(u"CAPTURES"); open_view->push_dir(captures_dir);
open_view->on_changed = [this](fs::path path) { open_view->on_changed = [this](fs::path path) {
add_entry(std::move(path)); add_entry(std::move(path));
}; };

View File

@ -337,7 +337,7 @@ ReconView::ReconView(NavigationView& nav)
// set record View // set record View
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16}, record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
u"AUTO_AUDIO", u"AUDIO", u"AUTO_AUDIO", audio_dir,
RecordView::FileType::WAV, 4096, 4); RecordView::FileType::WAV, 4096, 4);
record_view->set_filename_date_frequency(true); record_view->set_filename_date_frequency(true);
record_view->set_auto_trim(false); record_view->set_auto_trim(false);
@ -1170,18 +1170,18 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
if (new_mod == SPEC_MODULATION) { if (new_mod == SPEC_MODULATION) {
if (persistent_memory::recon_repeat_recorded()) { if (persistent_memory::recon_repeat_recorded()) {
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16}, record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
u"RECON_REPEAT.C16", u"CAPTURES", u"RECON_REPEAT.C16", captures_dir,
RecordView::FileType::RawS16, 16384, 3); RecordView::FileType::RawS16, 16384, 3);
record_view->set_filename_as_is(true); record_view->set_filename_as_is(true);
} else { } else {
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16}, record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
u"AUTO_RAW", u"CAPTURES", u"AUTO_RAW", captures_dir,
RecordView::FileType::RawS16, 16384, 3); RecordView::FileType::RawS16, 16384, 3);
record_view->set_filename_date_frequency(true); record_view->set_filename_date_frequency(true);
} }
} else { } else {
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16}, record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
u"AUTO_AUDIO", u"AUDIO", u"AUTO_AUDIO", audio_dir,
RecordView::FileType::WAV, 4096, 4); RecordView::FileType::WAV, 4096, 4);
record_view->set_filename_date_frequency(true); record_view->set_filename_date_frequency(true);
} }

View File

@ -38,6 +38,7 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "file.hpp" #include "file.hpp"
#include "file_path.hpp"
#include "app_settings.hpp" #include "app_settings.hpp"
#include "radio_state.hpp" #include "radio_state.hpp"
#include "ui_recon_settings.hpp" #include "ui_recon_settings.hpp"
@ -181,7 +182,6 @@ class ReconView : public View {
const std::filesystem::path repeat_rec_file = u"RECON_REPEAT.C16"; const std::filesystem::path repeat_rec_file = u"RECON_REPEAT.C16";
const std::filesystem::path repeat_rec_meta = u"RECON_REPEAT.TXT"; const std::filesystem::path repeat_rec_meta = u"RECON_REPEAT.TXT";
const std::filesystem::path repeat_rec_path = u"CAPTURES";
const size_t repeat_read_size{16384}; const size_t repeat_read_size{16384};
const size_t repeat_buffer_count{3}; const size_t repeat_buffer_count{3};
int8_t repeat_cur_rep = 0; int8_t repeat_cur_rep = 0;

View File

@ -30,6 +30,7 @@
#include "freqman_db.hpp" #include "freqman_db.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "file_path.hpp"
using namespace std; using namespace std;
using namespace portapack; using namespace portapack;

View File

@ -32,6 +32,7 @@
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "ui_textentry.hpp" #include "ui_textentry.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -246,7 +247,7 @@ RemoteEntryEditView::RemoteEntryEditView(
field_path.on_select = [this, &nav](TextField&) { field_path.on_select = [this, &nav](TextField&) {
auto open_view = nav.push<FileLoadView>(".C*"); auto open_view = nav.push<FileLoadView>(".C*");
open_view->push_dir(u"CAPTURES"); open_view->push_dir(captures_dir);
open_view->on_changed = [this](fs::path path) { open_view->on_changed = [this](fs::path path) {
load_path(std::move(path)); load_path(std::move(path));
refresh_ui(); refresh_ui();
@ -355,7 +356,7 @@ RemoteView::RemoteView(
Dim waterfall_height = waterfall_bottom - waterfall_top; Dim waterfall_height = waterfall_bottom - waterfall_top;
waterfall.set_parent_rect({0, waterfall_top, screen_width, waterfall_height}); waterfall.set_parent_rect({0, waterfall_top, screen_width, waterfall_height});
ensure_directory(u"REMOTES"); ensure_directory(remotes_dir);
// Load the previously loaded remote if exists. // Load the previously loaded remote if exists.
if (!load_remote(settings_.remote_path)) if (!load_remote(settings_.remote_path))
@ -527,7 +528,7 @@ void RemoteView::new_remote() {
void RemoteView::open_remote() { void RemoteView::open_remote() {
auto open_view = nav_.push<FileLoadView>(".REM"); auto open_view = nav_.push<FileLoadView>(".REM");
open_view->push_dir(u"REMOTES"); open_view->push_dir(remotes_dir);
open_view->on_changed = [this](fs::path path) { open_view->on_changed = [this](fs::path path) {
save_remote(); save_remote();
load_remote(std::move(path)); load_remote(std::move(path));
@ -538,7 +539,7 @@ void RemoteView::open_remote() {
void RemoteView::init_remote() { void RemoteView::init_remote() {
model_ = {"<Unnamed Remote>", {}}; model_ = {"<Unnamed Remote>", {}};
reset_buttons(); reset_buttons();
set_remote_path(next_filename_matching_pattern(u"/REMOTES/REMOTE_????.REM")); set_remote_path(next_filename_matching_pattern(remotes_dir / u"REMOTE_????.REM"));
set_needs_save(false); set_needs_save(false);
if (remote_path_.empty()) if (remote_path_.empty())

View File

@ -26,6 +26,7 @@
#include "optional.hpp" #include "optional.hpp"
#include "ui_fileman.hpp" #include "ui_fileman.hpp"
#include "ui_freqman.hpp" #include "ui_freqman.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
namespace fs = std::filesystem; namespace fs = std::filesystem;

View File

@ -41,6 +41,7 @@ using namespace lpc43xx;
using namespace portapack; using namespace portapack;
#include "file.hpp" #include "file.hpp"
#include "file_path.hpp"
namespace fs = std::filesystem; namespace fs = std::filesystem;
#include "string_format.hpp" #include "string_format.hpp"
@ -571,17 +572,17 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
check_use_sdcard_for_pmem.on_select = [this](Checkbox&, bool v) { check_use_sdcard_for_pmem.on_select = [this](Checkbox&, bool v) {
File pmem_flag_file_handle; File pmem_flag_file_handle;
if (v) { if (v) {
if (fs::file_exists(PMEM_FILEFLAG)) { if (fs::file_exists(settings_dir / PMEM_FILEFLAG)) {
text_pmem_status.set("P.Mem flag file present."); text_pmem_status.set("P.Mem flag file present.");
} else { } else {
auto error = pmem_flag_file_handle.create(PMEM_FILEFLAG); auto error = pmem_flag_file_handle.create(settings_dir / PMEM_FILEFLAG);
if (error) if (error)
text_pmem_status.set("Error creating P.Mem File!"); text_pmem_status.set("Error creating P.Mem File!");
else else
text_pmem_status.set("P.Mem flag file created."); text_pmem_status.set("P.Mem flag file created.");
} }
} else { } else {
auto result = delete_file(PMEM_FILEFLAG); auto result = delete_file(settings_dir / PMEM_FILEFLAG);
if (result.code() != FR_OK) if (result.code() != FR_OK)
text_pmem_status.set("Error deleting P.Mem flag!"); text_pmem_status.set("Error deleting P.Mem flag!");
else else
@ -717,10 +718,10 @@ AppSettingsView::AppSettingsView(
menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8}); menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8});
ensure_directory(SETTINGS_DIR); ensure_directory(settings_dir);
for (const auto& entry : std::filesystem::directory_iterator(SETTINGS_DIR, u"*.ini")) { for (const auto& entry : std::filesystem::directory_iterator(settings_dir, u"*.ini")) {
auto path = (std::filesystem::path)SETTINGS_DIR / entry.path(); auto path = settings_dir / entry.path();
menu_view.add_item({path.filename().string().substr(0, 26), menu_view.add_item({path.filename().string().substr(0, 26),
ui::Color::dark_cyan(), ui::Color::dark_cyan(),

View File

@ -25,6 +25,7 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "audio.hpp" #include "audio.hpp"
#include "app_settings.hpp" #include "app_settings.hpp"
#include "file_path.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include <cstring> #include <cstring>
@ -112,7 +113,7 @@ SondeView::SondeView(NavigationView& nav)
logger = std::make_unique<SondeLogger>(); logger = std::make_unique<SondeLogger>();
if (logger) if (logger)
logger->append(LOG_ROOT_DIR "/SONDE.TXT"); logger->append(logs_dir / u"SONDE.TXT");
audio::output::start(); audio::output::start();

View File

@ -38,7 +38,7 @@
class TestLogger { class TestLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }

View File

@ -27,6 +27,7 @@
#include "event_m0.hpp" #include "event_m0.hpp"
#include "file_reader.hpp" #include "file_reader.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "file_path.hpp"
#include <cstring> #include <cstring>
@ -142,7 +143,7 @@ WhipCalcView::WhipCalcView(NavigationView& nav)
void WhipCalcView::load_antenna_db() { void WhipCalcView::load_antenna_db() {
File antennas_file; File antennas_file;
auto error = antennas_file.open("/WHIPCALC/ANTENNAS.TXT"); auto error = antennas_file.open(whipcalc_dir / u"ANTENNAS.TXT");
if (error) if (error)
return; return;

View File

@ -23,10 +23,11 @@
#include "database.hpp" #include "database.hpp"
#include "file.hpp" #include "file.hpp"
#include "file_path.hpp"
#include <cstring> #include <cstring>
int database::retrieve_mid_record(MidDBRecord* record, std::string search_term) { int database::retrieve_mid_record(MidDBRecord* record, std::string search_term) {
file_path = "AIS/mids.db"; file_path = ais_dir / u"mids.db";
index_item_length = 4; index_item_length = 4;
record_length = 32; record_length = 32;
@ -36,7 +37,7 @@ int database::retrieve_mid_record(MidDBRecord* record, std::string search_term)
} }
int database::retrieve_airline_record(AirlinesDBRecord* record, std::string search_term) { int database::retrieve_airline_record(AirlinesDBRecord* record, std::string search_term) {
file_path = "ADSB/airlines.db"; file_path = adsb_dir / u"airlines.db";
index_item_length = 4; index_item_length = 4;
record_length = 64; record_length = 64;
@ -46,7 +47,7 @@ int database::retrieve_airline_record(AirlinesDBRecord* record, std::string sear
} }
int database::retrieve_aircraft_record(AircraftDBRecord* record, std::string search_term) { int database::retrieve_aircraft_record(AircraftDBRecord* record, std::string search_term) {
file_path = "ADSB/icao24.db"; file_path = adsb_dir / u"icao24.db";
index_item_length = 7; index_item_length = 7;
record_length = 146; record_length = 146;
@ -55,7 +56,7 @@ int database::retrieve_aircraft_record(AircraftDBRecord* record, std::string sea
return (result); return (result);
} }
int database::retrieve_record(std::string file_path, int index_item_length, int record_length, void* record, std::string search_term) { int database::retrieve_record(std::filesystem::path file_path, int index_item_length, int record_length, void* record, std::string search_term) {
if (search_term.empty()) if (search_term.empty())
return DATABASE_RECORD_NOT_FOUND; return DATABASE_RECORD_NOT_FOUND;

View File

@ -61,9 +61,9 @@ class database {
int retrieve_aircraft_record(AircraftDBRecord* record, std::string search_term); int retrieve_aircraft_record(AircraftDBRecord* record, std::string search_term);
private: private:
std::string file_path = ""; // path inclusing filename std::filesystem::path file_path = ""; // path including filename
int index_item_length = 0; // length of index item int index_item_length = 0; // length of index item
int record_length = 0; // length of record int record_length = 0; // length of record
File db_file{}; File db_file{};
int number_of_records = 0; int number_of_records = 0;
@ -74,7 +74,7 @@ class database {
int result = 0; int result = 0;
int retrieve_record(std::string file_path, int index_item_length, int record_length, void* record, std::string search_term); int retrieve_record(std::filesystem::path file_path, int index_item_length, int record_length, void* record, std::string search_term);
}; };
#endif /*__DATABASE_H__*/ #endif /*__DATABASE_H__*/

View File

@ -32,6 +32,7 @@
#include "string_format.hpp" #include "string_format.hpp"
#include "ui_styles.hpp" #include "ui_styles.hpp"
#include "irq_controls.hpp" #include "irq_controls.hpp"
#include "file_path.hpp"
using namespace ui; using namespace ui;
@ -266,7 +267,6 @@ bool stack_dump() {
bool memory_dump(uint32_t* addr_start, uint32_t num_words, bool stack_flag) { bool memory_dump(uint32_t* addr_start, uint32_t num_words, bool stack_flag) {
Painter painter; Painter painter;
std::string debug_dir = "DEBUG";
std::filesystem::path filename{}; std::filesystem::path filename{};
File dump_file{}; File dump_file{};
bool error; bool error;
@ -277,7 +277,7 @@ bool memory_dump(uint32_t* addr_start, uint32_t num_words, bool stack_flag) {
bool data_found{false}; bool data_found{false};
ensure_directory(debug_dir); ensure_directory(debug_dir);
filename = next_filename_matching_pattern(debug_dir + "/" + (stack_flag ? "STACK" : "MEMORY") + "_DUMP_????.TXT"); filename = next_filename_matching_pattern(debug_dir + (stack_flag ? u"/STACK" : u"/MEMORY") + u"_DUMP_????.TXT");
error = filename.empty(); error = filename.empty();
if (!error) if (!error)
error = dump_file.create(filename) != 0; error = dump_file.create(filename) != 0;

View File

@ -29,6 +29,7 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "file_path.hpp"
using namespace portapack; using namespace portapack;
using namespace modems; using namespace modems;
@ -84,7 +85,7 @@ AFSKRxView::AFSKRxView(NavigationView& nav)
logger = std::make_unique<AFSKLogger>(); logger = std::make_unique<AFSKLogger>();
if (logger) if (logger)
logger->append(LOG_ROOT_DIR "/AFSK.TXT"); logger->append(logs_dir / u"AFSK.TXT");
// Auto-configure modem for LCR RX (will be removed later) // Auto-configure modem for LCR RX (will be removed later)
baseband::set_afsk(persistent_memory::modem_baudrate(), 8, 0, false); baseband::set_afsk(persistent_memory::modem_baudrate(), 8, 0, false);

View File

@ -40,7 +40,7 @@ namespace ui::external_app::afsk_rx {
class AFSKLogger { class AFSKLogger {
public: public:
Optional<File::Error> append(const std::string& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename); return log_file.append(filename);
} }

View File

@ -76,15 +76,15 @@ SpectrumPainterView::SpectrumPainterView(
transmitter_model.set_rf_amp(rf_amp); transmitter_model.set_rf_amp(rf_amp);
}; };
input_image.on_input_avaliable = [this]() { input_image.on_input_available = [this]() {
image_input_avaliable = true; image_input_available = true;
}; };
button_play.on_select = [this](ImageButton&) { button_play.on_select = [this](ImageButton&) {
if (tx_active == false) { if (tx_active == false) {
tx_mode = tab_view.selected(); tx_mode = tab_view.selected();
if (tx_mode == 0 && image_input_avaliable == false) if (tx_mode == 0 && image_input_available == false)
return; return;
/* By experimental test measurement, we got a good painted spectrum quality when selecting /* By experimental test measurement, we got a good painted spectrum quality when selecting
a BW GUI App range from 100k ... 2M aprox. In that range , the best TX LPF filter = 1M75 (the min) a BW GUI App range from 100k ... 2M aprox. In that range , the best TX LPF filter = 1M75 (the min)

View File

@ -61,7 +61,7 @@ class SpectrumPainterView : public View {
app_settings::SettingsManager settings_{ app_settings::SettingsManager settings_{
"tx_painter", app_settings::Mode::TX}; "tx_painter", app_settings::Mode::TX};
bool image_input_avaliable{false}; bool image_input_available{false};
bool tx_active{false}; bool tx_active{false};
uint32_t tx_mode{0}; uint32_t tx_mode{0};
uint16_t tx_current_line{0}; uint16_t tx_current_line{0};

View File

@ -28,6 +28,7 @@
#include "io_file.hpp" #include "io_file.hpp"
#include "file.hpp" #include "file.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "file_path.hpp"
namespace ui::external_app::spainter { namespace ui::external_app::spainter {
@ -39,15 +40,14 @@ SpectrumInputImageView::SpectrumInputImageView(NavigationView& nav) {
button_load_image.on_select = [this, &nav](Button&) { button_load_image.on_select = [this, &nav](Button&) {
auto open_view = nav.push<FileLoadView>(".bmp"); auto open_view = nav.push<FileLoadView>(".bmp");
constexpr auto data_directory = u"SPECTRUM"; ensure_directory(spectrum_dir);
ensure_directory(data_directory); open_view->push_dir(spectrum_dir);
open_view->push_dir(data_directory);
open_view->on_changed = [this](std::filesystem::path new_file_path) { open_view->on_changed = [this](std::filesystem::path new_file_path) {
this->file = new_file_path.string(); this->file = new_file_path.string();
painted = false; painted = false;
this->set_dirty(); this->set_dirty();
this->on_input_avaliable(); this->on_input_available();
}; };
}; };
} }

View File

@ -46,7 +46,7 @@ class SpectrumInputImageView : public View {
uint16_t get_height(); uint16_t get_height();
std::vector<uint8_t> get_line(uint16_t); std::vector<uint8_t> get_line(uint16_t);
std::function<void()> on_input_avaliable{}; std::function<void()> on_input_available{};
private: private:
bool painted{false}; bool painted{false};

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "file_path.hpp"
#include "file.hpp"
const std::filesystem::path adsb_dir = u"ADSB";
const std::filesystem::path ais_dir = u"AIS";
const std::filesystem::path aprs_dir = u"APRS";
const std::filesystem::path audio_dir = u"AUDIO";
const std::filesystem::path blerx_dir = u"BLERX";
const std::filesystem::path bletx_dir = u"BLETX";
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 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 screenshots_dir = u"SCREENSHOTS";
const std::filesystem::path settings_dir = u"SETTINGS";
const std::filesystem::path spectrum_dir = u"SPECTRUM";
const std::filesystem::path splash_dir = u"SPLASH";
const std::filesystem::path sstv_dir = u"SSTV";
const std::filesystem::path wav_dir = u"WAV";
const std::filesystem::path whipcalc_dir = u"WHIPCALC";

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2024 Mark Thompson
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef __FILE_PATH_H__
#define __FILE_PATH_H__
#include "file.hpp"
extern const std::filesystem::path adsb_dir;
extern const std::filesystem::path ais_dir;
extern const std::filesystem::path aprs_dir;
extern const std::filesystem::path audio_dir;
extern const std::filesystem::path blerx_dir;
extern const std::filesystem::path bletx_dir;
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 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 screenshots_dir;
extern const std::filesystem::path settings_dir;
extern const std::filesystem::path spectrum_dir;
extern const std::filesystem::path splash_dir;
extern const std::filesystem::path sstv_dir;
extern const std::filesystem::path wav_dir;
extern const std::filesystem::path whipcalc_dir;
#endif /* __FILE_PATH_H__ */

View File

@ -29,6 +29,7 @@
#include "string_format.hpp" #include "string_format.hpp"
#include "tone_key.hpp" #include "tone_key.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "file_path.hpp"
#include <array> #include <array>
#include <cctype> #include <cctype>
@ -37,7 +38,6 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
const std::filesystem::path freqman_dir{u"/FREQMAN"};
const std::filesystem::path freqman_extension{u".TXT"}; const std::filesystem::path freqman_extension{u".TXT"};
// NB: Don't include UI headers to keep this code unit testable. // NB: Don't include UI headers to keep this code unit testable.

View File

@ -36,7 +36,6 @@
#include <vector> #include <vector>
/* Defined in freqman_db.cpp */ /* Defined in freqman_db.cpp */
extern const std::filesystem::path freqman_dir;
extern const std::filesystem::path freqman_extension; extern const std::filesystem::path freqman_extension;
using freqman_index_t = uint8_t; using freqman_index_t = uint8_t;

View File

@ -27,8 +27,6 @@
#include "file.hpp" #include "file.hpp"
#include "rtc_time.hpp" #include "rtc_time.hpp"
#define LOG_ROOT_DIR "LOGS"
class LogFile { class LogFile {
public: public:
Optional<File::Error> append(const std::filesystem::path& filename) { Optional<File::Error> append(const std::filesystem::path& filename) {

View File

@ -34,6 +34,7 @@ using namespace portapack;
#include "complex.hpp" #include "complex.hpp"
#include "ui_styles.hpp" #include "ui_styles.hpp"
#include "ui_font_fixed_5x8.hpp" #include "ui_font_fixed_5x8.hpp"
#include "file_path.hpp"
namespace ui { namespace ui {
@ -447,7 +448,7 @@ void GeoMap::move(const float lon, const float lat) {
} }
bool GeoMap::init() { bool GeoMap::init() {
auto result = map_file.open("ADSB/world_map.bin"); auto result = map_file.open(adsb_dir / u"world_map.bin");
map_opened = !result.is_valid(); map_opened = !result.is_valid();
if (map_opened) { if (map_opened) {
@ -613,7 +614,7 @@ void GeoMapView::focus() {
geopos.focus(); geopos.focus();
if (!geomap.map_file_opened()) if (!geomap.map_file_opened())
nav_.display_modal("No map", "No world_map.bin file in\n/ADSB/ directory", ABORT); nav_.display_modal("No map", "No world_map.bin file in\n/" + adsb_dir.string() + "/ directory", ABORT);
} }
void GeoMapView::update_my_position(float lat, float lon, int32_t altitude) { void GeoMapView::update_my_position(float lat, float lon, int32_t altitude) {

View File

@ -106,6 +106,7 @@
#include "file.hpp" #include "file.hpp"
#include "file_reader.hpp" #include "file_reader.hpp"
#include "png_writer.hpp" #include "png_writer.hpp"
#include "file_path.hpp"
using portapack::receiver_model; using portapack::receiver_model;
using portapack::transmitter_model; using portapack::transmitter_model;
@ -473,8 +474,8 @@ void SystemStatusView::on_bias_tee() {
} }
void SystemStatusView::on_camera() { void SystemStatusView::on_camera() {
ensure_directory("SCREENSHOTS"); ensure_directory(screenshots_dir);
auto path = next_filename_matching_pattern(u"SCREENSHOTS/SCR_????.PNG"); auto path = next_filename_matching_pattern(screenshots_dir / u"SCR_????.PNG");
if (path.empty()) if (path.empty())
return; return;
@ -535,7 +536,7 @@ void SystemStatusView::rtc_battery_workaround() {
} }
} }
} else { } else {
ensure_directory(SETTINGS_DIR); ensure_directory(settings_dir);
make_new_file(DATE_FILEFLAG); make_new_file(DATE_FILEFLAG);
year = 1980; year = 1980;

View File

@ -44,6 +44,7 @@
#include "ui_flash_utility.hpp" #include "ui_flash_utility.hpp"
#include "untar.hpp" #include "untar.hpp"
#include "ui_widget.hpp" #include "ui_widget.hpp"
#include "file_path.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
#include "usb_serial_shell_filesystem.hpp" #include "usb_serial_shell_filesystem.hpp"
@ -167,8 +168,8 @@ static void cmd_screenshot(BaseSequentialStream* chp, int argc, char* argv[]) {
(void)argc; (void)argc;
(void)argv; (void)argv;
ensure_directory("SCREENSHOTS"); ensure_directory(screenshots_dir);
auto path = next_filename_matching_pattern(u"SCREENSHOTS/SCR_????.PNG"); auto path = next_filename_matching_pattern(screenshots_dir / u"SCR_????.PNG");
if (path.empty()) if (path.empty())
return; return;
@ -1037,9 +1038,9 @@ static void cmd_settingsreset(BaseSequentialStream* chp, int argc, char* argv[])
if (!nav) return; if (!nav) return;
nav->home(true); // to exit all running apps nav->home(true); // to exit all running apps
for (const auto& entry : std::filesystem::directory_iterator(SETTINGS_DIR, u"*.ini")) { for (const auto& entry : std::filesystem::directory_iterator(settings_dir, u"*.ini")) {
if (std::filesystem::is_regular_file(entry.status())) { if (std::filesystem::is_regular_file(entry.status())) {
std::filesystem::path pth = SETTINGS_DIR; std::filesystem::path pth = settings_dir;
pth += u"/" + entry.path(); pth += u"/" + entry.path();
chprintf(chp, pth.string().c_str()); chprintf(chp, pth.string().c_str());
chprintf(chp, "\r\n"); chprintf(chp, "\r\n");

View File

@ -37,6 +37,7 @@
#include "ui_flash_utility.hpp" #include "ui_flash_utility.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "rtc_time.hpp" #include "rtc_time.hpp"
#include "file_path.hpp"
#include <algorithm> #include <algorithm>
#include <string> #include <string>
@ -1105,14 +1106,14 @@ void set_menu_color(Color v) {
// PMem to sdcard settings // PMem to sdcard settings
bool should_use_sdcard_for_pmem() { bool should_use_sdcard_for_pmem() {
return std::filesystem::file_exists(PMEM_FILEFLAG); return std::filesystem::file_exists(settings_dir / PMEM_FILEFLAG);
} }
int save_persistent_settings_to_file() { int save_persistent_settings_to_file() {
File outfile; File outfile;
ensure_directory(SETTINGS_DIR); ensure_directory(settings_dir);
auto error = outfile.create(PMEM_SETTING_FILE); auto error = outfile.create(settings_dir / PMEM_SETTING_FILE);
if (error) if (error)
return false; return false;
@ -1122,7 +1123,7 @@ int save_persistent_settings_to_file() {
int load_persistent_settings_from_file() { int load_persistent_settings_from_file() {
File infile; File infile;
auto error = infile.open(PMEM_SETTING_FILE); auto error = infile.open(settings_dir / PMEM_SETTING_FILE);
if (error) if (error)
return false; return false;

View File

@ -37,10 +37,10 @@
#include "ui.hpp" #include "ui.hpp"
// persistent memory from/to sdcard flag file // persistent memory from/to sdcard flag file
#define PMEM_FILEFLAG u"/SETTINGS/PMEM_FILEFLAG" #define PMEM_FILEFLAG u"PMEM_FILEFLAG"
// persistent memory from/to sdcard flag file // persistent memory from/to sdcard flag file
#define PMEM_SETTING_FILE u"/SETTINGS/pmem_settings" #define PMEM_SETTING_FILE u"pmem_settings"
#define PMEM_SIZE_BYTES 256 // total amount of pmem space in bytes, including checksum #define PMEM_SIZE_BYTES 256 // total amount of pmem space in bytes, including checksum
#define PMEM_SIZE_WORDS (PMEM_SIZE_BYTES / 4) #define PMEM_SIZE_WORDS (PMEM_SIZE_BYTES / 4)