flipperzero-firmware/applications/services/storage/storage_glue.h
Sergey Gavrilov 777a4d109d
[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>
2023-03-02 03:57:27 +10:00

74 lines
2.2 KiB
C

#pragma once
#include <furi.h>
#include "filesystem_api_internal.h"
#include <m-list.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { ST_EXT = 0, ST_INT = 1, ST_ANY, ST_ERROR } StorageType;
typedef struct StorageData StorageData;
typedef struct {
void (*tick)(StorageData* storage);
} StorageApi;
typedef struct {
File* file;
void* file_data;
FuriString* path;
} StorageFile;
typedef enum {
StorageStatusOK, /**< storage ok */
StorageStatusNotReady, /**< storage not ready (not initialized or waiting for data storage to appear) */
StorageStatusNotMounted, /**< datastore appeared, but we cannot mount it */
StorageStatusNoFS, /**< datastore appeared and mounted, but does not have a file system */
StorageStatusNotAccessible, /**< datastore appeared and mounted, but not available */
StorageStatusErrorInternal, /**< any other internal error */
} StorageStatus;
void storage_file_init(StorageFile* obj);
void storage_file_init_set(StorageFile* obj, const StorageFile* src);
void storage_file_set(StorageFile* obj, const StorageFile* src);
void storage_file_clear(StorageFile* obj);
void storage_data_init(StorageData* storage);
StorageStatus storage_data_status(StorageData* storage);
const char* storage_data_status_text(StorageData* storage);
void storage_data_timestamp(StorageData* storage);
uint32_t storage_data_get_timestamp(StorageData* storage);
LIST_DEF(
StorageFileList,
StorageFile,
(INIT(API_2(storage_file_init)),
SET(API_6(storage_file_init_set)),
INIT_SET(API_6(storage_file_set)),
CLEAR(API_2(storage_file_clear))))
struct StorageData {
const FS_Api* fs_api;
StorageApi api;
void* data;
StorageStatus status;
StorageFileList_t files;
uint32_t timestamp;
};
bool storage_has_file(const File* file, StorageData* storage_data);
bool storage_path_already_open(FuriString* path, StorageFileList_t files);
void storage_set_storage_file_data(const File* file, void* file_data, StorageData* storage);
void* storage_get_storage_file_data(const File* file, StorageData* storage);
void storage_push_storage_file(File* file, FuriString* path, StorageData* storage);
bool storage_pop_storage_file(File* file, StorageData* storage);
#ifdef __cplusplus
}
#endif