Loading...
Searching...
No Matches
storage_glue.h
1#pragma once
2
3#include <furi.h>
4#include "filesystem_api_internal.h"
5#include <m-list.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11typedef enum {
12 ST_EXT = 0,
13 ST_INT = 1,
14 ST_ANY,
15 ST_ERROR
16} StorageType;
17
18typedef struct StorageData StorageData;
19
20typedef struct {
21 void (*tick)(StorageData* storage);
23
24typedef struct {
25 File* file;
26 void* file_data;
27 FuriString* path;
29
30typedef enum {
31 StorageStatusOK,
32 StorageStatusNotReady,
33 StorageStatusNotMounted,
34 StorageStatusNoFS,
35 StorageStatusNotAccessible,
36 StorageStatusErrorInternal,
37} StorageStatus;
38
39void storage_file_init(StorageFile* obj);
40void storage_file_init_set(StorageFile* obj, const StorageFile* src);
41void storage_file_set(StorageFile* obj, const StorageFile* src);
42void storage_file_clear(StorageFile* obj);
43
44void storage_data_init(StorageData* storage);
45StorageStatus storage_data_status(StorageData* storage);
46const char* storage_data_status_text(StorageData* storage);
47void storage_data_timestamp(StorageData* storage);
48uint32_t storage_data_get_timestamp(StorageData* storage);
49
50LIST_DEF(
51 StorageFileList,
53 (INIT(API_2(storage_file_init)),
54 SET(API_6(storage_file_init_set)),
55 INIT_SET(API_6(storage_file_set)),
56 CLEAR(API_2(storage_file_clear))))
57
58struct StorageData {
59 const FS_Api* fs_api;
60 StorageApi api;
61 void* data;
62 StorageStatus status;
63 StorageFileList_t files;
64 uint32_t timestamp;
65};
66
67bool storage_has_file(const File* file, StorageData* storage_data);
68bool storage_path_already_open(FuriString* path, StorageData* storage_data);
69
70void storage_set_storage_file_data(const File* file, void* file_data, StorageData* storage);
71void* storage_get_storage_file_data(const File* file, StorageData* storage);
72
73void storage_push_storage_file(File* file, FuriString* path, StorageData* storage);
74bool storage_pop_storage_file(File* file, StorageData* storage);
75
76size_t storage_open_files_count(StorageData* storage);
77
78#ifdef __cplusplus
79}
80#endif
Full filesystem api structure.
Definition filesystem_api_internal.h:189
Structure that hold file index and returned api errors.
Definition filesystem_api_internal.h:17
Definition string.c:4
Definition storage_glue.h:20
Definition storage_glue.h:24