Files
tactility/TactilityKernel/source/paths.cpp
Ken Van Hoeylandt 643cbc3806 Implement posix app loading (#643)
- Added POSIX desktop support for SDK builds, application packaging, and integration testing.
- Added POSIX filesystem partitions and improved application path handling.
- Added simulator support for loading and running applications dynamically.
- Improved simulator task stack handling and display startup reliability.
- Improved simulator display scaling, resizing, high-DPI support, and pointer accuracy.
- Fixed LVGL timers and input polling on POSIX. (fixes simulator with Linux on some Intel graphics platforms)
- Standardized data paths across platforms.
- Logging now works via separate task: this allows apps to write to log without it affecting their stdout (for apps that output text as relevant date for other apps, like the File Selection app)
- Fixes for app stdio
2026-08-31 22:09:04 +02:00

58 lines
1.6 KiB
C++

// SPDX-License-Identifier: Apache-2.0
#include <tactility/paths.h>
#include <tactility/device.h>
#include <tactility/drivers/sdcard.h>
#include <tactility/filesystem/file_system.h>
#include <cstdio>
#include <cstring>
static error_t paths_get_data_root_path(char* out_path, size_t out_path_size) {
#if defined(CONFIG_TT_USER_DATA_LOCATION_INTERNAL)
#ifdef ESP_PLATFORM
const char* mount_point = "/data";
#else
const char* mount_point = "data";
#endif
if (std::strlen(mount_point) + 1 > out_path_size) {
return ERROR_BUFFER_OVERFLOW;
}
std::strcpy(out_path, mount_point);
return ERROR_NONE;
#elif defined(CONFIG_TT_USER_DATA_LOCATION_SD)
FileSystem* found = nullptr;
file_system_for_each(&found, [](FileSystem* fs, void* context) {
auto* owner = file_system_get_owner(fs);
if (owner == nullptr || device_get_type(owner) != &SDCARD_TYPE) {
return true;
}
*static_cast<FileSystem**>(context) = fs;
return false;
});
if (found == nullptr) {
return ERROR_NOT_FOUND;
}
return file_system_get_path(found, out_path, out_path_size);
#else
#error CONFIG_TT_USER_DATA_* not set or unsupported
#endif
}
extern "C" {
error_t paths_get_data_path(char* out_path, size_t out_path_size) {
char root[64];
error_t error = paths_get_data_root_path(root, sizeof(root));
if (error != ERROR_NONE) {
return error;
}
int written = std::snprintf(out_path, out_path_size, "%s/tactility", root);
if (written < 0 || (size_t)written >= out_path_size) {
return ERROR_BUFFER_OVERFLOW;
}
return ERROR_NONE;
}
} // extern "C"