]> git.seodisparate.com - SimpleArchiver/commitdiff
Update file_format for v1
authorStephen Seo <seo.disparate@gmail.com>
Fri, 4 Oct 2024 05:02:54 +0000 (14:02 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 4 Oct 2024 05:02:54 +0000 (14:02 +0900)
Size of bytes for files per chunk was changed from 2 bytes to 4 bytes.

file_format.md
file_format_1_example_0
file_format_1_example_1
src/archiver.c

index 67c58662bec7fd339ee16089bd8ec8a603123e9d..4e395447a2e39abe1a977f6cd7a3a4da34adaf2b 100644 (file)
@@ -149,7 +149,7 @@ archive.
 
 Following the chunk-count bytes, the following bytes are added for each chunk:
 
-1. 2 bytes that are a 16-bit unsigned integer "file count" in big-endian.
+1. 4 bytes that are a 32-bit unsigned integer "file count" in big-endian.
 
 The following bytes are added for each file within the current chunk:
 
index f28c89ed130d3445f8c84ba0f3f3521d17cc134e..a39ecf63812a798e5e1ca4829331e322f43c68ec 100644 (file)
Binary files a/file_format_1_example_0 and b/file_format_1_example_0 differ
index b56b56c6a7fcd8bee2c0dc7cee54354451196ddc..696a49f01f3583aeee48051f72487a10d1e15a7b 100644 (file)
Binary files a/file_format_1_example_1 and b/file_format_1_example_1 differ
index 0644051114cd4a874fa559d134d33cb0d8fcf48f..a0c37fb581cda7498eef548d91ce19ac7ec11242 100644 (file)
@@ -2974,13 +2974,13 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract,
   for (uint32_t chunk_idx = 0; chunk_idx < chunk_count; ++chunk_idx) {
     fprintf(stderr, "CHUNK %3u of %3u\n", chunk_idx + 1, chunk_count);
 
-    if (fread(buf, 1, 2, in_f) != 2) {
+    if (fread(buf, 1, 4, in_f) != 4) {
       return SDAS_INVALID_FILE;
     }
-    memcpy(&u16, buf, 2);
-    simple_archiver_helper_16_bit_be(&u16);
+    memcpy(&u32, buf, 4);
+    simple_archiver_helper_32_bit_be(&u32);
 
-    const uint16_t file_count = u16;
+    const uint32_t file_count = u32;
 
     __attribute__((cleanup(simple_archiver_list_free)))
     SDArchiverLinkedList *file_info_list = simple_archiver_list_init();
@@ -2988,7 +2988,7 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract,
     __attribute__((cleanup(cleanup_internal_file_info)))
     SDArchiverInternalFileInfo *file_info = NULL;
 
-    for (uint16_t file_idx = 0; file_idx < file_count; ++file_idx) {
+    for (uint32_t file_idx = 0; file_idx < file_count; ++file_idx) {
       file_info = malloc(sizeof(SDArchiverInternalFileInfo));
       memset(file_info, 0, sizeof(SDArchiverInternalFileInfo));