mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-15 00:08:11 -07:00
Updater: Progressbar even with huge files --nobuild
This commit is contained in:
@@ -33,6 +33,9 @@ typedef struct TarArchive {
|
||||
mtar_t tar;
|
||||
tar_unpack_file_cb unpack_cb;
|
||||
void* unpack_cb_context;
|
||||
|
||||
tar_unpack_read_cb read_cb;
|
||||
void* read_cb_context;
|
||||
} TarArchive;
|
||||
|
||||
/* Plain file backend - uncompressed, supports read and write */
|
||||
@@ -211,6 +214,12 @@ void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callb
|
||||
archive->unpack_cb_context = context;
|
||||
}
|
||||
|
||||
void tar_archive_set_read_callback(TarArchive* archive, tar_unpack_read_cb callback, void* context) {
|
||||
furi_check(archive);
|
||||
archive->read_cb = callback;
|
||||
archive->read_cb_context = context;
|
||||
}
|
||||
|
||||
static int tar_archive_entry_counter(mtar_t* tar, const mtar_header_t* header, void* param) {
|
||||
UNUSED(tar);
|
||||
UNUSED(header);
|
||||
@@ -321,6 +330,13 @@ static bool archive_extract_current_file(TarArchive* archive, const char* dst_pa
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(archive->read_cb) {
|
||||
archive->read_cb(
|
||||
storage_file_tell(archive->stream),
|
||||
storage_file_size(archive->stream),
|
||||
archive->read_cb_context);
|
||||
}
|
||||
}
|
||||
} while(false);
|
||||
storage_file_free(out_file);
|
||||
|
||||
@@ -140,6 +140,11 @@ typedef bool (*tar_unpack_file_cb)(const char* name, bool is_directory, void* co
|
||||
*/
|
||||
void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callback, void* context);
|
||||
|
||||
/* Optional read progress callback on unpacking */
|
||||
typedef void (*tar_unpack_read_cb)(size_t progress, size_t total, void* context);
|
||||
|
||||
void tar_archive_set_read_callback(TarArchive* archive, tar_unpack_read_cb callback, void* context);
|
||||
|
||||
/* Low-level API */
|
||||
|
||||
/** Add tar archive directory header
|
||||
|
||||
Reference in New Issue
Block a user