an efficient binary archive format
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

update spec

zach 31c1f8c9 13a55bb6

+8 -7
+5 -4
SPEC.md
··· 13 13 | `0x00` | **Header** | 8-byte magic identification string. | 14 14 | `0x08` | **Data Payload** | Sequential blobs of raw or compressed data. | 15 15 | `Variable` | **Index** | A sequence of metadata entries and filenames. | 16 - | `EOF - 20` | **Footer** | Pointer to the index and file count. | 16 + | `EOF - 16` | **Footer** | Pointer to the index and file count. | 17 17 18 18 --- 19 19 ··· 40 40 | `name_len` | 2 bytes | u16 | Length of the following filename string. | 41 41 | `comp_type` | 1 byte | u8 | `0` = Raw, `1` = Zstd. | 42 42 | `reserved` | 1 byte | u8 | Alignment padding. | 43 + | `filename` | variable | utf8 | Filename string 43 44 44 45 **Padding:** After the filename string, the file MUST be padded with null bytes until the next 8-byte boundary is reached. 45 46 46 47 ### 2.4 Footer 47 - The last 20 bytes of the file contain the lookup information required to parse the archive. 48 + The last 16 bytes of the file contain the lookup information required to parse the archive. 48 49 49 50 | Field | Size | Type | Description | 50 51 | :--- | :--- | :--- | :--- | 51 52 | `index_offset` | 8 bytes | u64 | Absolute offset to the start of the Index. | 52 - | `entry_count` | 4 bytes | u32 | Total number of entries in the file. | 53 + | `entry_count` | 8 bytes | u32 | Total number of entries in the file. | 53 54 54 55 --- 55 56 ··· 59 60 To read a Bindle file: 60 61 1. Validate the file size (must be at least 28 bytes). 61 62 2. Read the first 8 bytes and the last 8 bytes to verify the `BINDL001` magic. 62 - 3. Read the `index_offset` from the footer (EOF - 20). 63 + 3. Read the `index_offset` from the footer (EOF - 16). 63 64 4. Seek to `index_offset` and iterate `entry_count` times to populate an in-memory map of files. 64 65 65 66 ### 3.2 Writing Logic (Atomic Updates)
+3 -3
src/lib.rs
··· 30 30 #[derive(FromBytes, Unaligned, IntoBytes, Immutable, Debug)] 31 31 struct Footer { 32 32 pub index_offset: [u8; 8], 33 - pub entry_count: [u8; 4], 33 + pub entry_count: [u8; 8], 34 34 } 35 35 36 36 pub struct Bindle { ··· 88 88 89 89 // If magic is valid, proceed to parse the index 90 90 let data_end = u64::from_le_bytes(footer.index_offset); 91 - let count = u32::from_le_bytes(footer.entry_count); 91 + let count = u64::from_le_bytes(footer.entry_count); 92 92 let mut entries = Vec::with_capacity(count as usize); 93 93 94 94 let mut cursor = data_end as usize; ··· 244 244 245 245 let footer = Footer { 246 246 index_offset: index_start.to_le_bytes(), 247 - entry_count: (self.entries.len() as u32).to_le_bytes(), 247 + entry_count: (self.entries.len() as u64).to_le_bytes(), 248 248 }; 249 249 250 250 self.file.write_all(footer.as_bytes())?;