Add storage_file_expand()

This commit is contained in:
Willy-JL
2023-08-02 23:33:27 +02:00
parent 070fb17485
commit e8f11e5521
9 changed files with 80 additions and 1 deletions

View File

@@ -396,6 +396,22 @@ static uint64_t storage_ext_file_tell(void* ctx, File* file) {
return position;
}
static bool storage_ext_file_expand(void* ctx, File* file, const uint64_t size) {
#ifdef FURI_RAM_EXEC
UNUSED(ctx);
UNUSED(file);
UNUSED(size);
return FSE_NOT_READY;
#else
StorageData* storage = ctx;
SDFile* file_data = storage_get_storage_file_data(file, storage);
file->internal_error_id = f_expand(file_data, size, 1);
file->error_id = storage_ext_parse_error(file->internal_error_id);
return (file->error_id == FSE_OK);
#endif
}
static bool storage_ext_file_truncate(void* ctx, File* file) {
#ifdef FURI_RAM_EXEC
UNUSED(ctx);
@@ -609,6 +625,7 @@ static const FS_Api fs_api = {
.write = storage_ext_file_write,
.seek = storage_ext_file_seek,
.tell = storage_ext_file_tell,
.expand = storage_ext_file_expand,
.truncate = storage_ext_file_truncate,
.size = storage_ext_file_size,
.sync = storage_ext_file_sync,

View File

@@ -455,6 +455,13 @@ static uint64_t storage_int_file_tell(void* ctx, File* file) {
return position;
}
static bool storage_int_file_expand(void* ctx, File* file, const uint64_t size) {
UNUSED(ctx);
UNUSED(file);
UNUSED(size);
return false;
}
static bool storage_int_file_truncate(void* ctx, File* file) {
StorageData* storage = ctx;
lfs_t* lfs = lfs_get_from_storage(storage);
@@ -703,6 +710,7 @@ static const FS_Api fs_api = {
.write = storage_int_file_write,
.seek = storage_int_file_seek,
.tell = storage_int_file_tell,
.expand = storage_int_file_expand,
.truncate = storage_int_file_truncate,
.size = storage_int_file_size,
.sync = storage_int_file_sync,