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
56 lines
2.1 KiB
C++
56 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace roro::files {
|
|
|
|
enum class FileSort : uint8_t { Name, Date, Size };
|
|
|
|
// A folder's entries for the Storage App (F1, Q129, Q136): 256 at most, the names packed into
|
|
// one buffer, about 10 KB when full. A bigger folder keeps the first 256 by name, whatever order
|
|
// the card lists them in, and counts the rest.
|
|
class FileList {
|
|
public:
|
|
static constexpr size_t kMax = 256;
|
|
|
|
void clear();
|
|
void add(const char* name, uint32_t size, uint32_t modified, bool folder);
|
|
void sort(FileSort by); // folders first, by name; then files by name, newest or biggest first
|
|
|
|
size_t count() const { return entries_.size(); }
|
|
size_t more() const { return more_; } // entries that didn't fit
|
|
// By position after sort().
|
|
const char* name(size_t i) const { return names_.data() + entries_[order_[i]].name; }
|
|
uint32_t size(size_t i) const { return entries_[order_[i]].size; }
|
|
uint32_t modified(size_t i) const { return entries_[order_[i]].modified; } // Unix time, 0 if unknown
|
|
bool folder(size_t i) const { return entries_[order_[i]].folder; }
|
|
int find(const std::string& name) const; // position, or -1
|
|
size_t bytes() const; // memory held
|
|
|
|
private:
|
|
struct Entry {
|
|
uint32_t name; // offset into names_
|
|
uint32_t size, modified;
|
|
bool folder;
|
|
};
|
|
bool before(const Entry& a, const Entry& b, FileSort by) const;
|
|
void compact();
|
|
|
|
std::vector<Entry> entries_;
|
|
std::vector<uint16_t> order_;
|
|
std::vector<char> names_;
|
|
size_t more_ = 0, wasted_ = 0;
|
|
};
|
|
|
|
// What a row shows on the right (Q129): "folder", or "1.2 KB 2026-10-05". A file dated before
|
|
// 2020 was written before the clock was set: "-" (Q137). Local time.
|
|
std::string rowDetail(bool folder, uint32_t size, uint32_t modified);
|
|
std::string formatStamp(uint32_t modified);
|
|
// A name cut to `maxChars` for a row, from the middle: the start and the extension stay readable.
|
|
std::string fitName(const std::string& name, size_t maxChars); // "2026-10-05 20:00", or "-"
|
|
|
|
} // namespace roro::files
|