[FL-3055] Getter for application data path (#2181)
* Threads: application id * Unit tests: appsdata getter test * Unit tests: moar test cases for appsdata getter * Unit tests: remove folders after test * Storage: dir_is_exist, migrate, + unit_tests * Plugins: migration * Storage: common_exists, moar unit_tests 4 "common_migrate", "common_migrate" and "common_merge" bugfixes * Storage: use FuriString for path handling * Storage API: send caller thread id with path * Storage: remove StorageType field in storage file list * Storage: simplify processing * Storage API: send caller thread id with path everywhere * Storage: /app alias, unit tests and path creation * Storage, path helper: remove unused * Examples: app data example * App plugins: use new VFS path * Storage: file_info_is_dir * Services: handle alias if the service accepts a path. * App plugins: fixes * Make PVS happy * Storage: fix storage_merge_recursive * Storage: rename process_aliases to resolve_path. Rename APPS_DATA to APP_DATA. * Apps: use predefined macro instead of raw paths. Example Apps Data: README fixes. * Storage: rename storage_common_resolve_path to storage_common_resolve_path_and_ensure_app_directory * Api: fix version * Storage: rename alias message * Storage: do not create app folders in path resolving process in certain cases. --------- Co-authored-by: Astra <93453568+Astrrra@users.noreply.github.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -10,10 +10,12 @@ extern "C" {
|
||||
#define STORAGE_INT_PATH_PREFIX "/int"
|
||||
#define STORAGE_EXT_PATH_PREFIX "/ext"
|
||||
#define STORAGE_ANY_PATH_PREFIX "/any"
|
||||
#define STORAGE_APP_DATA_PATH_PREFIX "/app"
|
||||
|
||||
#define INT_PATH(path) STORAGE_INT_PATH_PREFIX "/" path
|
||||
#define EXT_PATH(path) STORAGE_EXT_PATH_PREFIX "/" path
|
||||
#define ANY_PATH(path) STORAGE_ANY_PATH_PREFIX "/" path
|
||||
#define APP_DATA_PATH(path) STORAGE_APP_DATA_PATH_PREFIX "/" path
|
||||
|
||||
#define RECORD_STORAGE "storage"
|
||||
|
||||
@@ -175,6 +177,15 @@ bool storage_dir_read(File* file, FileInfo* fileinfo, char* name, uint16_t name_
|
||||
*/
|
||||
bool storage_dir_rewind(File* file);
|
||||
|
||||
/**
|
||||
* @brief Check that dir exists
|
||||
*
|
||||
* @param storage
|
||||
* @param path
|
||||
* @return bool
|
||||
*/
|
||||
bool storage_dir_exists(Storage* storage, const char* path);
|
||||
|
||||
/******************* Common Functions *******************/
|
||||
|
||||
/** Retrieves unix timestamp of last access
|
||||
@@ -246,6 +257,36 @@ FS_Error storage_common_fs_info(
|
||||
uint64_t* total_space,
|
||||
uint64_t* free_space);
|
||||
|
||||
/**
|
||||
* @brief Parse aliases in path and replace them with real path
|
||||
* Also will create special folders if they are not exist
|
||||
*
|
||||
* @param storage
|
||||
* @param path
|
||||
* @return bool
|
||||
*/
|
||||
void storage_common_resolve_path_and_ensure_app_directory(Storage* storage, FuriString* path);
|
||||
|
||||
/**
|
||||
* @brief Move content of one folder to another, with rename of all conflicting files.
|
||||
* Source folder will be deleted if the migration is successful.
|
||||
*
|
||||
* @param storage
|
||||
* @param source
|
||||
* @param dest
|
||||
* @return FS_Error
|
||||
*/
|
||||
FS_Error storage_common_migrate(Storage* storage, const char* source, const char* dest);
|
||||
|
||||
/**
|
||||
* @brief Check that file or dir exists
|
||||
*
|
||||
* @param storage
|
||||
* @param path
|
||||
* @return bool
|
||||
*/
|
||||
bool storage_common_exists(Storage* storage, const char* path);
|
||||
|
||||
/******************* Error Functions *******************/
|
||||
|
||||
/** Retrieves the error text from the error id
|
||||
|
Reference in New Issue
Block a user