Merge develop into main (#304)
## New - Read property files with `PropertiesFile` - Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`) - Create registry for CPU affinity and update code to make use of it - `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps - `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app::notes::start(path)` function. - WiFi settings moved from NVS to properties file. - Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up. - Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards ## Improvements - Update TinyUSB to `1.7.6~1` - Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability. - `tt::string` functionality improvements - Rename `AppRegistry` to `AppRegistration` - Rename `ServiceRegistry` to `ServiceRegistration` - Cleanup in `Notes.cpp` - `FileTest.cpp` fix for PC - Created `TestFile` helper class for tests, which automatically deletes files after the test. - Renamed `Partitions.h` to `MountPoints.h` - Created `std::string getMountPoints()` function for easy re-use - Other code quality improvements - `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument ## Fixes - ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
This commit is contained in:
committed by
GitHub
parent
fbaff8cbac
commit
ee5a5a7181
@@ -7,28 +7,23 @@
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @warning SD card access requires a locking mechanism:
|
||||
* @warning When using this in the Tactility main project, use `file::getLock()` or `file::withLock()`
|
||||
*/
|
||||
namespace tt::file {
|
||||
|
||||
/** File types for `dirent`'s `d_type`. */
|
||||
enum {
|
||||
TT_DT_UNKNOWN = 0,
|
||||
#define TT_DT_UNKNOWN TT_DT_UNKNOWN // Unknown type
|
||||
TT_DT_FIFO = 1,
|
||||
#define TT_DT_FIFO TT_DT_FIFO // Named pipe or FIFO
|
||||
TT_DT_CHR = 2,
|
||||
#define TT_DT_CHR TT_DT_CHR // Character device
|
||||
TT_DT_DIR = 4,
|
||||
#define TT_DT_DIR TT_DT_DIR // Directory
|
||||
TT_DT_BLK = 6,
|
||||
#define TT_DT_BLK TT_DT_BLK // Block device
|
||||
TT_DT_REG = 8,
|
||||
#define TT_DT_REG TT_DT_REG // Regular file
|
||||
TT_DT_LNK = 10,
|
||||
#define TT_DT_LNK TT_DT_LNK // Symbolic link
|
||||
TT_DT_SOCK = 12,
|
||||
#define TT_DT_SOCK TT_DT_SOCK // Local-domain socket
|
||||
TT_DT_WHT = 14
|
||||
#define TT_DT_WHT TT_DT_WHT // Whiteout inodes
|
||||
TT_DT_UNKNOWN = 0, // Unknown type
|
||||
TT_DT_FIFO = 1, // Named pipe or FIFO
|
||||
TT_DT_CHR = 2, // Character device
|
||||
TT_DT_DIR = 4, // Directory
|
||||
TT_DT_BLK = 6, // Block device
|
||||
TT_DT_REG = 8, // Regular file
|
||||
TT_DT_LNK = 10, // Symbolic link
|
||||
TT_DT_SOCK = 12, // Local-domain socket
|
||||
TT_DT_WHT = 14 // Whiteout inodes
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -92,6 +87,10 @@ bool direntSortAlphaAndType(const dirent& left, const dirent& right);
|
||||
/** A filter for filtering out "." and ".." */
|
||||
int direntFilterDotEntries(const dirent* entry);
|
||||
|
||||
bool isFile(const std::string& path);
|
||||
|
||||
bool isDirectory(const std::string& path);
|
||||
|
||||
/**
|
||||
* A scandir()-like implementation that works on ESP32.
|
||||
* It does not return "." and ".." items but otherwise functions the same.
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "File.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace tt::file {
|
||||
|
||||
class ObjectFileReader {
|
||||
|
||||
private:
|
||||
|
||||
const std::string filePath;
|
||||
const uint32_t recordSize = 0;
|
||||
|
||||
std::unique_ptr<FILE, FileCloser> file;
|
||||
uint32_t recordCount = 0;
|
||||
uint32_t recordVersion = 0;
|
||||
uint32_t recordsRead = 0;
|
||||
|
||||
public:
|
||||
|
||||
ObjectFileReader(std::string filePath, uint32_t recordSize) :
|
||||
filePath(std::move(filePath)),
|
||||
recordSize(recordSize)
|
||||
{}
|
||||
|
||||
bool open();
|
||||
void close();
|
||||
|
||||
bool hasNext() const { return recordsRead < recordCount; }
|
||||
bool readNext(void* output);
|
||||
|
||||
uint32_t getRecordCount() const { return recordCount; }
|
||||
uint32_t getRecordSize() const { return recordSize; }
|
||||
uint32_t getRecordVersion() const { return recordVersion; }
|
||||
};
|
||||
|
||||
class ObjectFileWriter {
|
||||
|
||||
private:
|
||||
|
||||
const std::string filePath;
|
||||
const uint32_t recordSize;
|
||||
const uint32_t recordVersion;
|
||||
const bool append;
|
||||
|
||||
std::unique_ptr<FILE, FileCloser> file;
|
||||
uint32_t recordsWritten = 0;
|
||||
|
||||
public:
|
||||
|
||||
ObjectFileWriter(std::string filePath, uint32_t recordSize, uint32_t recordVersion, bool append) :
|
||||
filePath(std::move(filePath)),
|
||||
recordSize(recordSize),
|
||||
recordVersion(recordVersion),
|
||||
append(append)
|
||||
{}
|
||||
|
||||
|
||||
~ObjectFileWriter() {
|
||||
if (file != nullptr) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
bool open();
|
||||
void close();
|
||||
|
||||
bool write(void* data);
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user