App path updates and fixes

It's not super consistent yet, but I'll fix that later
This commit is contained in:
Ken Van Hoeylandt 2026-08-19 22:13:45 +02:00
parent ef4d0c6cdc
commit 5ff98ab38c
14 changed files with 42 additions and 29 deletions

View File

@ -15,7 +15,7 @@ FileSystem* findSdcardFileSystem(bool mustBeMounted);
std::string getUserDataRootPath();
std::string getUserDataPath();
std::string getDataPath();
std::string getTempPath();

View File

@ -51,7 +51,7 @@ std::string getUserDataRootPath() {
#endif
}
std::string getUserDataPath() {
std::string getDataPath() {
#ifdef ESP_PLATFORM
return getUserDataRootPath() + "/tactility";
#else
@ -60,15 +60,15 @@ std::string getUserDataPath() {
}
std::string getTempPath() {
return getUserDataPath() + "/tmp";
return getDataPath() + "/tmp";
}
std::string getAppInstallPath() {
return getUserDataPath() + "/app";
return getDataPath() + "/app";
}
std::string getUserHomePath() {
return getUserDataPath() + "/user";
return getDataPath() + "/user";
}
std::string getAppInstallPath(const std::string& appId) {

View File

@ -318,7 +318,7 @@ static void registerAndStartServices() {
}
void createTempDirectory() {
auto data_path = getUserDataPath();
auto data_path = getDataPath();
auto temp_path = std::format("{}/tmp", data_path);
if (!file::isDirectory(temp_path)) {
FileMutex mutex;

View File

@ -25,7 +25,7 @@ constexpr auto* KEY_AUTO_CONNECT = "autoConnect";
constexpr auto* KEY_PROFILE_ID = "profileId";
static std::string getSettingsFilePath() {
return getUserDataPath() + "/service/bluetooth";
return getDataPath() + "/service/bluetooth";
}
std::string addrToHex(const std::array<uint8_t, 6>& addr) {

View File

@ -11,7 +11,7 @@ namespace tt::bluetooth::settings {
constexpr auto* TAG = "BluetoothSettings";
static std::string getSettingsPath() {
return getUserDataPath() + "/settings/bluetooth.settings";
return getDataPath() + "/settings/bluetooth.properties";
}
constexpr auto* KEY_ENABLE_ON_BOOT = "enableOnBoot";

View File

@ -1,5 +1,3 @@
#include <service/paths.h>
#include <Tactility/network/NtpPrivate.h>
#include <tactility/log.h>
@ -24,11 +22,10 @@ static bool processedSyncEvent = false;
static bool getPreferencesPath(std::string& outPath) {
char root[128];
// Not really a service, but this is the best way of organising it for now
if (service_paths_get_user_data_directory("tactility.ntp", root, sizeof(root)) != ERROR_NONE) {
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
return false;
}
outPath = std::string(root) + "/time.properties";
outPath = std::string(root) + "/settings/ntp.properties";
return true;
}

View File

@ -1450,7 +1450,7 @@ esp_err_t WebServerService::handleApiScreenshot(httpd_req_t* request) {
#if TT_FEATURE_SCREENSHOT_ENABLED
// Determine save location: prefer SD card root if mounted, otherwise /data
std::string save_path = getUserDataPath();
std::string save_path = getDataPath();
// Find next available filename with incrementing number
std::string screenshot_path;

View File

@ -126,7 +126,7 @@ void bootSplashInit() {
getMainDispatcher().dispatch([] {
LOG_I(TAG, "bootSplashInit dispatch begin");
// Import any provisioning files placed on the system data partition.
const std::string provisioning_path = file::getChildPath(getUserDataPath(), "provisioning");
const std::string provisioning_path = file::getChildPath(getDataPath(), "provisioning");
if (file::isDirectory(provisioning_path)) {
importWifiApSettingsFromDir(provisioning_path);
} else {

View File

@ -1,5 +1,7 @@
#include <Tactility/settings/AudioSettings.h>
#include "tactility/paths.h"
#include <Tactility/DeprecatedPaths.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
@ -12,8 +14,14 @@
namespace tt::settings::audio {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/audio.properties";
static bool getSettingsFilePath(std::string& outPath) {
char root[128];
// Not really a service, but this is the best way of organising it for now
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
return false;
}
outPath = std::string(root) + "/settings/audio.properties";
return true;
}
constexpr auto* SETTINGS_KEY_INPUT_ENABLED = "inputEnabled";
@ -56,7 +64,11 @@ static std::string toString(float value) {
}
bool load(AudioSettings& settings) {
auto settings_path = getSettingsFilePath();
std::string settings_path;
if (getSettingsFilePath(settings_path)) {
return false;
}
if (!file::isFile(settings_path)) {
return false;
}
@ -103,10 +115,16 @@ bool save(const AudioSettings& settings) {
map[SETTINGS_KEY_OUTPUT_MUTED] = toString(settings.outputMuted);
map[SETTINGS_KEY_INPUT_VOLUME] = toString(settings.inputVolume);
map[SETTINGS_KEY_OUTPUT_VOLUME] = toString(settings.outputVolume);
auto settings_path = getSettingsFilePath();
std::string settings_path;
if (getSettingsFilePath(settings_path)) {
return false;
}
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
return false;
}
return file::savePropertiesFile(settings_path, map);
}

View File

@ -14,7 +14,7 @@ constexpr auto* PROPERTIES_KEY_LAUNCHER_APP_ID = "launcherAppId";
constexpr auto* PROPERTIES_KEY_AUTO_START_APP_ID = "autoStartAppId";
static std::string getPropertiesFilePath() {
return std::format(PROPERTIES_FILE_FORMAT, getUserDataPath());
return std::format(PROPERTIES_FILE_FORMAT, getDataPath());
}
bool loadBootSettings(BootSettings& properties) {

View File

@ -9,7 +9,7 @@
namespace tt::settings::keyboard {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/keyboard.properties";
return getDataPath() + "/settings/keyboard.properties";
}
constexpr auto* KEY_BACKLIGHT_ENABLED = "backlightEnabled";

View File

@ -21,12 +21,12 @@ static bool cached = false;
static SystemSettings cachedSettings;
static bool hasSystemSettingsFile() {
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
return file::isFile(file_path);
}
static bool loadSystemSettingsFromFile(SystemSettings& properties) {
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
LOG_I(TAG, "System settings loading from %s", file_path.c_str());
std::map<std::string, std::string> map;
if (!file::loadPropertiesFile(file_path, map)) {
@ -75,7 +75,7 @@ bool loadSystemSettings(SystemSettings& properties) {
}
bool saveSystemSettings(const SystemSettings& properties) {
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
std::map<std::string, std::string> map;
map["language"] = toString(properties.language);
map["timeFormat24h"] = properties.timeFormat24h ? "true" : "false";

View File

@ -13,7 +13,7 @@
namespace tt::settings::touch {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/touch-calibration.properties";
return getDataPath() + "/settings/touch-calibration.properties";
}
constexpr auto* SETTINGS_KEY_ENABLED = "enabled";

View File

@ -13,8 +13,6 @@
namespace tt::settings {
constexpr auto* TIME_SETTINGS_NAMESPACE = "time";
constexpr auto* TIMEZONE_PREFERENCES_KEY_NAME = "tz_name";
constexpr auto* TIMEZONE_PREFERENCES_KEY_CODE = "tz_code";
constexpr auto* TIMEZONE_PREFERENCES_KEY_TIME24 = "tz_time24";
@ -26,10 +24,10 @@ namespace {
bool getPreferencesPath(std::string& outPath) {
char root[128];
// Not really a service, but this is the best way of organising it for now
if (service_paths_get_user_data_directory("tactility.time", root, sizeof(root)) != ERROR_NONE) {
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
return false;
}
outPath = std::string(root) + "/" + TIME_SETTINGS_NAMESPACE + ".properties";
outPath = std::string(root) + "/settings/time.properties";
return true;
}