8#include "filesystem_api_defines.h"
9#include "storage_sd_api.h"
15#define STORAGE_INT_PATH_PREFIX "/int"
16#define STORAGE_EXT_PATH_PREFIX "/ext"
17#define STORAGE_ANY_PATH_PREFIX "/any"
18#define STORAGE_APP_DATA_PATH_PREFIX "/data"
19#define STORAGE_APP_ASSETS_PATH_PREFIX "/assets"
21#define INT_PATH(path) STORAGE_INT_PATH_PREFIX "/" path
22#define EXT_PATH(path) STORAGE_EXT_PATH_PREFIX "/" path
23#define ANY_PATH(path) STORAGE_ANY_PATH_PREFIX "/" path
24#define APP_DATA_PATH(path) STORAGE_APP_DATA_PATH_PREFIX "/" path
25#define APP_ASSETS_PATH(path) STORAGE_APP_ASSETS_PATH_PREFIX "/" path
27#define RECORD_STORAGE "storage"
91 FS_AccessMode access_mode,
92 FS_OpenMode open_mode);
359 uint64_t* total_space,
360 uint64_t* free_space);
514typedef void (*StorageNameConverter)(
FuriString*);
608 const char* filename,
609 const char* fileextension,
StorageEventType
Enumeration of events emitted by the storage through the PubSub system.
Definition storage.h:50
@ StorageEventTypeCardUnmount
SD card was unmounted.
Definition storage.h:52
@ StorageEventTypeDirClose
A directory was closed.
Definition storage.h:55
@ StorageEventTypeFileClose
A file was closed.
Definition storage.h:54
@ StorageEventTypeCardMountError
An error occurred during mounting of an SD card.
Definition storage.h:53
@ StorageEventTypeCardMount
SD card was mounted.
Definition storage.h:51
FS_Error storage_int_backup(Storage *storage, const char *dstname)
Back up the internal storage contents to a *.tar archive.
Definition storage_internal_api.c:5
bool storage_simply_remove(Storage *storage, const char *path)
Remove a file or a directory.
Definition storage_external_api.c:1029
bool storage_file_eof(File *file)
Check whether the current access position is at the end of the file.
Definition storage_external_api.c:274
bool storage_file_seek(File *file, uint32_t offset, bool from_start)
Change the current access position in a file.
Definition storage_external_api.c:222
FS_Error storage_common_remove(Storage *storage, const char *path)
Remove a file or a directory.
Definition storage_external_api.c:463
FS_Error storage_sd_status(Storage *storage)
Get SD card status.
Definition storage_external_api.c:916
bool storage_dir_rewind(File *file)
Change the access position to first item in the directory.
Definition storage_external_api.c:407
size_t storage_file_write(File *file, const void *buff, size_t bytes_to_write)
Write bytes from a buffer to a file.
Definition storage_external_api.c:203
FS_Error storage_sd_mount(Storage *storage)
Mount the SD card.
Definition storage_external_api.c:893
bool storage_simply_remove_recursive(Storage *storage, const char *path)
Recursively remove a file or a directory.
Definition storage_external_api.c:968
int32_t storage_file_get_internal_error(File *file)
Get the internal (storage-specific) numeric error identifier from a file instance.
Definition storage_external_api.c:861
FS_Error storage_common_copy(Storage *storage, const char *old_path, const char *new_path)
Copy the file to a new location.
Definition storage_external_api.c:579
void storage_file_free(File *file)
Free the file instance.
Definition storage_external_api.c:948
bool storage_file_close(File *file)
Close the file.
Definition storage_external_api.c:127
void storage_common_resolve_path_and_ensure_app_directory(Storage *storage, FuriString *path)
Parse aliases in a path and replace them with the real path.
Definition storage_external_api.c:781
FS_Error storage_common_stat(Storage *storage, const char *path, FileInfo *fileinfo)
Get information about a file or a directory.
Definition storage_external_api.c:447
FS_Error storage_sd_format(Storage *storage)
Format the SD Card.
Definition storage_external_api.c:873
bool storage_file_copy_to_file(File *source, File *destination, size_t size)
Copy data from a source file to the destination file.
Definition storage_external_api.c:297
FS_Error storage_common_fs_info(Storage *storage, const char *fs_path, uint64_t *total_space, uint64_t *free_space)
Get the general information about the storage.
Definition storage_external_api.c:759
const char * storage_error_get_desc(FS_Error error_id)
Get the textual description of a numeric error identifer.
Definition storage_external_api.c:852
bool storage_dir_close(File *file)
Close the directory.
Definition storage_external_api.c:372
bool storage_dir_exists(Storage *storage, const char *path)
Check whether a directory exists.
Definition storage_external_api.c:416
bool storage_file_open(File *file, const char *path, FS_AccessMode access_mode, FS_OpenMode open_mode)
Open an existing file or create a new one.
Definition storage_external_api.c:91
FS_Error storage_sd_unmount(Storage *storage)
Unmount the SD card.
Definition storage_external_api.c:883
bool storage_common_equivalent_path(Storage *storage, const char *path1, const char *path2)
Check whether two paths are equivalent.
Definition storage_external_api.c:842
FS_Error storage_file_get_error(File *file)
Get the numeric error identifier from a file instance.
Definition storage_external_api.c:856
bool storage_file_exists(Storage *storage, const char *path)
Check whether a file exists.
Definition storage_external_api.c:283
bool storage_dir_read(File *file, FileInfo *fileinfo, char *name, uint16_t name_length)
Get the next item in the directory.
Definition storage_external_api.c:390
bool storage_common_exists(Storage *storage, const char *path)
Check whether a file or a directory exists.
Definition storage_external_api.c:812
bool storage_file_truncate(File *file)
Truncate the file size to the current access position.
Definition storage_external_api.c:247
FS_Error storage_sd_info(Storage *storage, SDInfo *info)
Get SD card information.
Definition storage_external_api.c:903
bool storage_file_sync(File *file)
Synchronise the file cache with the actual storage.
Definition storage_external_api.c:265
FS_Error storage_common_merge(Storage *storage, const char *old_path, const char *new_path)
Copy the contents of one directory into another and rename all conflicting files.
Definition storage_external_api.c:674
bool storage_simply_mkdir(Storage *storage, const char *path)
Create a directory.
Definition storage_external_api.c:1037
bool storage_dir_open(File *file, const char *path)
Open a directory.
Definition storage_external_api.c:340
FS_Error storage_common_rename(Storage *storage, const char *old_path, const char *new_path)
Rename a file or a directory.
Definition storage_external_api.c:478
FS_Error storage_int_restore(Storage *storage, const char *dstname, StorageNameConverter converter)
Restore the internal storage contents from a *.tar archive.
Definition storage_internal_api.c:17
FS_Error storage_common_timestamp(Storage *storage, const char *path, uint32_t *timestamp)
Get the last access time in UNIX format.
Definition storage_external_api.c:431
FS_Error storage_common_mkdir(Storage *storage, const char *path)
Create a directory.
Definition storage_external_api.c:744
const char * storage_file_get_error_desc(File *file)
Get the textual description of a the last error associated with a file instance.
Definition storage_external_api.c:866
File * storage_file_alloc(Storage *storage)
Allocate and initialize a file instance.
Definition storage_external_api.c:926
bool storage_common_is_subdir(Storage *storage, const char *parent, const char *child)
Check whether a path is a subpath of another path.
Definition storage_external_api.c:846
size_t storage_file_read(File *file, void *buff, size_t bytes_to_read)
Read bytes from a file into a buffer.
Definition storage_external_api.c:186
void storage_get_next_filename(Storage *storage, const char *dirname, const char *filename, const char *fileextension, FuriString *nextfilename, uint8_t max_len)
Get the next free filename in a directory.
Definition storage_external_api.c:1045
uint64_t storage_file_size(File *file)
Get the file size.
Definition storage_external_api.c:256
bool storage_file_is_open(File *file)
Check whether the file is open.
Definition storage_external_api.c:938
FuriPubSub * storage_get_pubsub(Storage *storage)
Get the storage pubsub instance.
Definition storage_external_api.c:963
FS_Error storage_common_migrate(Storage *storage, const char *source, const char *dest)
Move the contents of source folder to destination one and rename all conflicting files.
Definition storage_external_api.c:796
uint64_t storage_file_tell(File *file)
Get the current access position.
Definition storage_external_api.c:238
bool storage_file_is_dir(File *file)
Check whether a file instance represents a directory.
Definition storage_external_api.c:943
Structure that hold file index and returned api errors.
Definition filesystem_api_internal.h:17
Structure that hold file info.
Definition filesystem_api_defines.h:48
Definition storage_sd_api.h:19
Storage event (passed to the PubSub callback).
Definition storage.h:61
StorageEventType type
Type of the event.
Definition storage.h:62
Definition storage_i.h:23