Public Access
The Storage App browses the SD card: folders first with sizes and dates, three sorts, one item at a time with a clipboard (c, x, v), rename, delete after counting what's inside, new folder, details. A listing holds 256 entries and says when a folder has more. FileOps does the card's work for the App and the console alike, one operation at a time on the storage task in turns of about 150 ms, so Logs and Captures are still written during a long copy. A copy shows progress, can be cancelled (what it wrote is taken back) and compares sizes after. The read-only rules are checked there: the firmware's top-level folders, /gemini/cache, and files being written (a Track, a Capture, an upload, today's IRC Logs). A listing reads the folder straight from FatFs: through the Arduino File, 329 entries took over two seconds. Viewers by type: text read a screen at a time whatever the file's size (logs open at the end), a hex dump, a Capture's packets as the LoRa Scanner lists them, a Track's summary, and an Update File checked as an install would check it, without writing anything. Tab shows any file as hex or text. Settings > Storage is gone: usage, Storage Clean-up and Erase are the App's Maintenance, behind a warning. The Storage Warning points there. The Clock sets the system time whatever its source, so files are dated correctly with a GNSS Fix alone (Q137). Console: cp, mv, mkdir, du, cancel; rm takes folders and follows the rules; ls shows dates; Debug Builds get `sd fill`. 424 host tests. Checked on the device: docs/milestones/F1.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
68 lines
2.1 KiB
C++
68 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <FS.h>
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "dialog_model.h"
|
|
#include "key_event.h"
|
|
#include "list_model.h"
|
|
#include "services/storage_service.h"
|
|
#include "services/update_service.h"
|
|
#include "text_pager.h"
|
|
#include "ui/canvas.h"
|
|
#include "ui/theme.h"
|
|
|
|
namespace roro {
|
|
|
|
// Looks inside a file for the Storage App (F1, Q134), by type: text read as it's scrolled, a hex
|
|
// dump, a Capture's packets, a Track's summary, an Update File's version and whether it's
|
|
// genuine. Tab switches to the text or the hex of the same file. Nothing here changes a file.
|
|
class FileViewer {
|
|
public:
|
|
FileViewer(StorageService& storage, UpdateService& update) : storage_(storage), update_(update) {}
|
|
|
|
void open(const std::string& path, uint32_t size);
|
|
void close();
|
|
bool onKey(const KeyEvent& e); // false: leave the viewer
|
|
bool update(uint32_t nowMs); // true: draw again
|
|
void draw(Canvas& c);
|
|
|
|
private:
|
|
enum class Mode { Text, Hex, Gpx, Pcap, Packet, Ota };
|
|
static constexpr int kRows = 8;
|
|
static constexpr int kCols = 38;
|
|
struct Scan; // what a storage job reads through a whole file for: shared with that job
|
|
|
|
size_t readAt(uint32_t offset, uint8_t* into, size_t len);
|
|
void show(Mode mode);
|
|
void startScan(Mode mode);
|
|
void refresh(); // reads what the screen shows, when it has moved
|
|
void openPacket(int index);
|
|
void scroll(int lines);
|
|
std::string title() const;
|
|
|
|
StorageService& storage_;
|
|
UpdateService& update_;
|
|
std::string path_;
|
|
uint32_t size_ = 0;
|
|
Mode mode_ = Mode::Text, base_ = Mode::Text;
|
|
std::shared_ptr<fs::File> file_; // opened and read on the storage task only
|
|
std::unique_ptr<files::TextPager> pager_;
|
|
uint32_t hexTop_ = 0; // in rows of eight bytes
|
|
std::vector<std::string> shown_; // the rows on screen
|
|
bool stale_ = true;
|
|
std::shared_ptr<Scan> scan_;
|
|
bool scanShown_ = false;
|
|
int shownPercent_ = -1;
|
|
ListModel packets_{kRows};
|
|
int rowsFrom_ = -1;
|
|
std::vector<std::string> details_;
|
|
int detailsTop_ = 0;
|
|
std::unique_ptr<DialogModel> confirm_;
|
|
};
|
|
|
|
} // namespace roro
|