Require SD card or >4MB flash (#545)

This commit is contained in:
Ken Van Hoeylandt
2026-07-03 23:56:03 +02:00
committed by GitHub
parent 90afba647e
commit 05720821f8
106 changed files with 403 additions and 603 deletions
+33 -18
View File
@@ -4,6 +4,9 @@
#include <Tactility/MountPoints.h>
#include <format>
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/sdcard.h>
#include <tactility/filesystem/file_system.h>
namespace tt {
@@ -20,14 +23,12 @@ bool findFirstMountedSdCardPath(std::string& path) {
FileSystem* findSdcardFileSystem(bool mustBeMounted) {
FileSystem* found = nullptr;
file_system_for_each(&found, [](auto* fs, void* context) {
char path[128];
if (file_system_get_path(fs, path, sizeof(path)) != ERROR_NONE) return true;
// TODO: Find a better way to identify SD card paths
if (std::string(path).starts_with("/sdcard")) {
*static_cast<FileSystem**>(context) = fs;
return false;
auto* owner = file_system_get_owner(fs);
if (owner == nullptr || device_get_type(owner) != &SDCARD_TYPE) {
return true;
}
return true;
*static_cast<FileSystem**>(context) = fs;
return false;
});
if (found && mustBeMounted && !file_system_is_mounted(found)) {
return nullptr;
@@ -35,24 +36,38 @@ FileSystem* findSdcardFileSystem(bool mustBeMounted) {
return found;
}
std::string getSystemRootPath() {
std::string root_path;
if (!findFirstMountedSdCardPath(root_path)) {
root_path = file::MOUNT_POINT_DATA;
}
return root_path;
std::string getUserDataRootPath() {
#ifdef CONFIG_TT_USER_DATA_LOCATION_INTERNAL
return file::MOUNT_POINT_DATA;
#elif CONFIG_TT_USER_DATA_LOCATION_SD
auto* fs = findSdcardFileSystem(false);
check(fs);
char fs_path[32];
check(file_system_get_path(fs, fs_path, sizeof(fs_path)) == ERROR_NONE);
return std::string(fs_path);
#else
#error CONFIG_TT_USER_DATA_* not set or unsupported
#endif
}
std::string getUserDataPath() {
#ifdef ESP_PLATFORM
return getUserDataRootPath() + "/tactility";
#else
return "data";
#endif
}
std::string getTempPath() {
return getSystemRootPath() + "/tmp";
return getUserDataPath() + "/tmp";
}
std::string getAppInstallPath() {
return getSystemRootPath() + "/app";
return getUserDataPath() + "/app";
}
std::string getUserPath() {
return getSystemRootPath() + "/user";
std::string getUserHomePath() {
return getUserDataPath() + "/user";
}
std::string getAppInstallPath(const std::string& appId) {
@@ -62,7 +77,7 @@ std::string getAppInstallPath(const std::string& appId) {
std::string getAppUserPath(const std::string& appId) {
assert(app::isValidId(appId));
return std::format("{}/app/{}", getUserPath(), appId);
return std::format("{}/app/{}", getUserHomePath(), appId);
}
}