BSB Developer Docs
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_BKP = 0,
13 ST_EXT = 1,
14 ST_MAX
15} StorageType;
16
17typedef struct StorageData StorageData;
18
19typedef struct {
20 void (*tick)(StorageData* storage);
22
23typedef struct {
24 File* file;
25 void* file_data;
26 FuriString* path;
27 FS_AccessMode access_mode;
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 bool read_only;
66};
67
68bool storage_has_file(const File* file, StorageData* storage_data);
69bool storage_path_already_open(
70 FuriString* path,
71 FS_AccessMode access_mode,
72 StorageData* storage_data);
73
74void storage_set_storage_file_data(const File* file, void* file_data, StorageData* storage);
75void* storage_get_storage_file_data(const File* file, StorageData* storage);
76
77void storage_push_storage_file(
78 File* file,
79 FuriString* path,
80 FS_AccessMode access_mode,
81 StorageData* storage);
82bool storage_pop_storage_file(File* file, StorageData* storage);
83
84size_t storage_open_files_count(StorageData* storage);
85
86void storage_set_read_only(StorageData* storage, bool read_only);
87bool storage_is_read_only(StorageData* storage);
88
89#ifdef __cplusplus
90}
91#endif
Full filesystem api structure.
Definition filesystem_api_internal.h:198
Structure that hold file index and returned api errors.
Definition filesystem_api_internal.h:18
Definition storage_glue.h:19
Definition storage_glue.h:23