-
-
Notifications
You must be signed in to change notification settings - Fork 3
K2A Archive Specification
K2Archive is a simple archive format designed for use with Amethyst Installer and Amethyst. It takes advantage of ZStandad compression to achieve a high compression ratio, and not get flagged by antivirus solutions (as we have had antivirus solutions clear a releases archive during the install process, breaking the installation process as a result).
Note: Offsets and sizes are denoted in bytes.
The archive format is designed as a series of blocks. A block is defined as a chunk of bytes, terminated by a magic number at the end.
Integers are stored in little-endian.
The entire archive is wrapped in a layer of ZStandard with compression level 6
.
An archive's blocks are denoted as followed:
-
The header - A block that is always present and contains information regarding this particular archive.
-
A collection of file blocks - All files and directories are stored in a file block.
A valid header consists of the following:
Field offset | Size | Name | Remarks |
---|---|---|---|
0 | 32 | MagicNumber | A magic number which is used to denote the that this is a valid archive. |
32 | 4 | FileCount | The number of file blocks to expect in this archive. |
A valid file block is denoted as follows:
Field offset | Size | Name | Remarks |
---|---|---|---|
0 | 100 | FilePath | The file path relative to the root of this archive. Files ending with a trailing slash are considered to be directories. |
100 | 4 | FileSize | The number of bytes in a file. This is an unsigned 64-bit integer. |
104 | 4 | BlockSize | The length of the block in bytes. This is an unsigned 64-bit integer. |
Following a file block is a ZStandard compressed byte*
of size FileSize
bytes. Exactly after that, is the next file block. Files are stored consecutively until the end of the file, or no header is found.
Things we should experiment with to try getting more aggressive compression ratios.
- See if per file compression makes sense after a threshold
- File blocks should have enum flags denoting further properties such as dir / file
I'm a masochist I'm sorry.