Files
fpk/docs/format.md
T

53 lines
1.3 KiB
Markdown

# FPK1 format
```
[ header ][ data blobs ][ string table ][ directory entries ]
```
## Header (28 bytes)
| Field | Type | Size | Offset |
|-----------------|-----------|------|--------|
| `magic` | char[4] | 4 | 0 |
| `entry_count` | uint64_t | 8 | 4 |
| `dir_offset` | uint64_t | 8 | 12 |
| `strtab_offset` | uint64_t | 8 | 20 |
`magic` = `"FPK1"`.
`FPK_HEADER_SIZE` (28): field-by-field, not `sizeof()`.
## Data blobs
Raw bytes, back-to-back, no padding, writer add order.
## String table
Paths, `/`-separated, NUL-terminated, back-to-back, entry order.
`strtab_offset` points here.
## Directory (25 bytes per entry)
| Field | Type | Size | Offset |
|---------------|----------|------|--------|
| `path_offset` | uint64_t | 8 | 0 |
| `data_offset` | uint64_t | 8 | 8 |
| `data_size` | uint64_t | 8 | 16 |
| `method` | uint8_t | 1 | 24 |
`path_offset` relative to `strtab_offset`. `data_offset` absolute.
`FPK_DIR_ENTRY_SIZE` (25): field-by-field, not `sizeof()`.
`dir_offset` points here, last region. File size = `dir_offset +
entry_count * FPK_DIR_ENTRY_SIZE`.
## Compression
`method`: reserved, v1 = `FPK_METHOD_STORE` (0) only.
## Endianness
Little-endian on disk, always. Big-endian host swaps on read/write.