This commit is contained in:
Willy-JL
2023-02-28 20:34:44 +00:00
parent dbfc57bfd3
commit fa8ed7f6e4
213 changed files with 2509 additions and 4465 deletions

View File

@@ -325,7 +325,7 @@ static bool animation_storage_load_frames(
FURI_CONST_ASSIGN(icon->width, width);
icon->frames = malloc(sizeof(const uint8_t*) * icon->frame_count);
bool frames_ok = true;
bool frames_ok = false;
File* file = storage_file_alloc(storage);
FileInfo file_info;
FuriString* filename;
@@ -333,41 +333,34 @@ static bool animation_storage_load_frames(
size_t max_filesize = ROUND_UP_TO(width, 8) * height + 2;
for(int i = 0; i < icon->frame_count; ++i) {
FURI_CONST_ASSIGN_PTR(icon->frames[i], 0);
if(frames_ok) {
frames_ok = false;
furi_string_printf(filename, "%s/%s/frame_%d.bm", ANIMATION_DIR, name, i);
do {
if(storage_common_stat(storage, furi_string_get_cstr(filename), &file_info) !=
FSE_OK)
break;
if(file_info.size > max_filesize) {
FURI_LOG_E(
TAG,
"Filesize %lld, max: %d (width %d, height %d)",
file_info.size,
max_filesize,
width,
height);
break;
}
if(!storage_file_open(
file, furi_string_get_cstr(filename), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_E(TAG, "Can't open file \'%s\'", furi_string_get_cstr(filename));
break;
}
frames_ok = false;
furi_string_printf(filename, "%s/%s/frame_%d.bm", ANIMATION_DIR, name, i);
FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(file_info.size));
if(storage_file_read(file, (void*)icon->frames[i], file_info.size) !=
file_info.size) {
FURI_LOG_E(TAG, "Read failed: \'%s\'", furi_string_get_cstr(filename));
break;
} else {
frames_ok = true;
}
storage_file_close(file);
} while(0);
if(storage_common_stat(storage, furi_string_get_cstr(filename), &file_info) != FSE_OK)
break;
if(file_info.size > max_filesize) {
FURI_LOG_E(
TAG,
"Filesize %lld, max: %d (width %d, height %d)",
file_info.size,
max_filesize,
width,
height);
break;
}
if(!storage_file_open(
file, furi_string_get_cstr(filename), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_E(TAG, "Can't open file \'%s\'", furi_string_get_cstr(filename));
break;
}
FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(file_info.size));
if(storage_file_read(file, (void*)icon->frames[i], file_info.size) != file_info.size) {
FURI_LOG_E(TAG, "Read failed: \'%s\'", furi_string_get_cstr(filename));
break;
}
storage_file_close(file);
frames_ok = true;
}
if(!frames_ok) {