Expand description
The CSF chunk container (“CSFCHUNK”) that wraps every .clip file.
All numbers are big endian (spec: docs/spec/01-container.md):
file header (24 bytes): "CSFCHUNK" u64 file size u64 offset of the first chunk (24)
chunk: 8-byte tag u64 body length body
CHNKHead body 40 bytes: u64 256, u64 offset of the CHNKSQLi chunk header,
u64 16, 16-byte file id
CHNKExta body: u64 40, 40-byte external id ("extrnlid" + 32 hex digits), payload
CHNKSQLi body: SQLite 3 database image
CHNKFoot body: empty; the last chunkCSP writes Head, every Exta, SQLi, Foot in this order. The table
ExternalChunk in the database maps each external id to the file offset
of its CHNKExta header. The parser keeps the original bytes, so a file
that is not changed is written back byte for byte.
Structs§
- Chunk
- One chunk: where its header and body are in the file.
- Container
- A parsed .clip container. Holds the original bytes.
- Container
Writer - Builds a new container: Head, the external chunks in the given order, SQLi, Foot, as CSP writes them.
- Head
- Contents of the CHNKHead chunk.
Enums§
- Chunk
Kind - Kind of a chunk, from its 8-byte tag.
Constants§
- CHUNK_
HEADER_ SIZE - Size of a chunk header (tag and body length).
- EXTERNAL_
ID_ LENGTH - Length of an external id.
- EXTERNAL_
ID_ PREFIX - How every external id starts.
- FILE_
HEADER_ SIZE - Size of the file header.
- FILE_
ID_ LENGTH - Length of the file id in CHNKHead.
- FILE_
MAGIC - The first 8 bytes of a .clip.
- HEAD_
BODY_ SIZE - Size of the CHNKHead body.
- HEAD_
VERSION - First value of the CHNKHead body.
- TAG_
EXTERNAL - Tag of an external chunk.
- TAG_
FOOTER - Tag of the last chunk.
- TAG_
HEAD - Tag of the head chunk.
- TAG_
SQLITE - Tag of the database chunk.
Functions§
- is_
external_ id - Whether
idlooks like the ids CSP writes (“extrnlid” + 32 hex digits).