19b11eb9a8
- Removed TactilityC, moved its symbols to existing modules and several new ones (pthread-module, c-symbols-module, cpp-symbols-module, posix-symbols-module, freertos-module). - Removed Firmware subproject and moved main() into Tactility subproject. - Strengthened application archive, path, version, stack-size, and device validation. - Moved symbol resolution for elf_loader to app-esp32-module. - Improved `struct Module` declarations and made module and symbol definitions in modules more consistent. - Removed old http download code from Tactility subproject. - Rename app-module's source files for consistency. - Add missing pthread symbols. - Kernel module symbols are now resolvable on all platforms.
70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#include <app/location.h>
|
|
#include <app/manager.h>
|
|
#include <app/paths.h>
|
|
#include <tactility/paths.h>
|
|
|
|
#include <cstdio>
|
|
|
|
extern "C" {
|
|
|
|
error_t app_paths_get_user_data_directory(const char* app_id, char* out_path, size_t out_path_size) {
|
|
char root[192];
|
|
error_t error = paths_get_data_path(root, sizeof(root));
|
|
if (error != ERROR_NONE) {
|
|
return error;
|
|
}
|
|
int written = std::snprintf(out_path, out_path_size, "%s/user/app/%s", root, app_id);
|
|
if (written < 0 || (size_t)written >= out_path_size) {
|
|
return ERROR_BUFFER_OVERFLOW;
|
|
}
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
error_t app_paths_get_user_data_path(const char* app_id, const char* child_path, char* out_path, size_t out_path_size) {
|
|
char directory[224];
|
|
error_t error = app_paths_get_user_data_directory(app_id, directory, sizeof(directory));
|
|
if (error != ERROR_NONE) {
|
|
return error;
|
|
}
|
|
int written = std::snprintf(out_path, out_path_size, "%s/%s", directory, child_path);
|
|
if (written < 0 || (size_t)written >= out_path_size) {
|
|
return ERROR_BUFFER_OVERFLOW;
|
|
}
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
error_t app_paths_get_assets_directory(const char* app_id, char* out_path, size_t out_path_size) {
|
|
AppManifest manifest;
|
|
error_t error = app_manager_find_manifest(app_id, &manifest);
|
|
if (error != ERROR_NONE) {
|
|
return error;
|
|
}
|
|
|
|
if (manifest.location.type != APP_LOCATION_PATH) {
|
|
return ERROR_NOT_FOUND;
|
|
}
|
|
|
|
int written = std::snprintf(out_path, out_path_size, "%s/assets", static_cast<const char*>(manifest.location.location));
|
|
if (written < 0 || (size_t)written >= out_path_size) {
|
|
return ERROR_BUFFER_OVERFLOW;
|
|
}
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
error_t app_paths_get_assets_path(const char* app_id, const char* child_path, char* out_path, size_t out_path_size) {
|
|
char directory[224];
|
|
error_t error = app_paths_get_assets_directory(app_id, directory, sizeof(directory));
|
|
if (error != ERROR_NONE) {
|
|
return error;
|
|
}
|
|
int written = std::snprintf(out_path, out_path_size, "%s/%s", directory, child_path);
|
|
if (written < 0 || (size_t)written >= out_path_size) {
|
|
return ERROR_BUFFER_OVERFLOW;
|
|
}
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
} // extern "C"
|