From eb1f09b55196ca06576b1f28106c89b91bd6cad6 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 2 Jul 2024 14:02:38 +0900 Subject: [PATCH] Revise file_format The changes should allow for the .simplearchive file to be directly outputted to standard out in a single pass. Resolves #10 . --- file_format.md | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/file_format.md b/file_format.md index c563124..b8ceb50 100644 --- a/file_format.md +++ b/file_format.md @@ -9,26 +9,30 @@ First 18 bytes of file will be: SIMPLE_ARCHIVE_VER Next 2 bytes is 16-bit unsigned integer "version" in big-endian. In this case, -will be zero. +it will be zero. -Next 4 bytes is 32-bit unsigned integer "file count" in big-endian which will -indicate the number of files in this archive. +Next 4 bytes are bit-flags. -For each file: +1. The first byte + 1. The first bit is set if de/compressor is set for this archive. + +The remaining unused flags are reserved for future revisions and are currently +ignored. + +If the previous "de/compressor is set" flag is enabled, then the next section is +added: + +1. 2 bytes is 16-bit unsigned integer "compressor cmd+args" in big-endian. +2. X bytes of "compressor cmd+args" (length defined by previous value). +3. 2 bytes is 16-bit unsigned integer "decompressor cmd+args" in big-endian. +4. X bytes of "decompressor cmd+args" (length defined by previous value). + +The next 4 bytes is 32-bit unsigned integer "file count" in big-endian which +will indicate the number of files in this archive. + +Following the file-count bytes, the following bytes are added for each file: 1. 2 bytes is 16-bit unsigned integer "filename length" in big-endian. -2. X bytes of filename (defined by previous value). -3. 2 bytes is 16-bit unsigned integer "compressor cmd+args" in big-endian. -4. X bytes of "compressor cmd+args" (defined by previous value). -5. 2 bytes is 16-bit unsigned integer "decompressor cmd+args" in big-endian. -6. X bytes of "decompressor cmd+args" (defined by previous value). -7. 8 bytes 64-bit unsigned integer "location of filename in this archive file". -8. 8 bytes 64-bit unsigned integer "size of filename in this archive file". - -Note that if archiving without compressor/decompressor, the byte values for -them will be 0 and there will be no strings for the compressor/decompressor -commands (lines 4 and 6 in previous per-file entry will not exist). - -The remaining bytes in the file are the files to be included in the archive file -concatenated together. Their locations and sizes should match what was listed -before. +2. X bytes of filename (length defined by previous value). +3. 8 bytes 64-bit unsigned integer "size of filename in this archive file". +4. X bytes file data (length defined by previous value).