Sarc: Difference between revisions
Jump to navigation
Jump to search
m (Correct hash function.) |
mNo edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Sarc is a file archive format. Files are typically accessed by a binary sorted | Sarc is a file archive format. Files are typically accessed by a binary sorted by a hash value derived from a custom hash function. For a more detailed article, see: https://github.com/Kinnay/Nintendo-File-Formats/wiki/SARC-File-Format | ||
=== Header === | === Header === | ||
Latest revision as of 20:25, 9 May 2023
Sarc is a file archive format. Files are typically accessed by a binary sorted by a hash value derived from a custom hash function. For a more detailed article, see: https://github.com/Kinnay/Nintendo-File-Formats/wiki/SARC-File-Format
Header
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x4 | u32 | Magic ("SARC" in big endian) |
| 0x4 | 0x2 | u16 | Size of header (0x14) |
| 0x6 | 0x2 | u16 | Endianess (Always reads as 0xfeff in platform's native endian) |
| 0x8 | 0x4 | u32 | Total file size |
| 0xc | 0x4 | u32 | File array offset |
| 0x10 | 0x4 | u32 | Alignment |
| 0x14 | 0x2 | u16 | Version |
| 0x16 | 0x2 | u16 | Reserved |
Sfat Section
The sfat section follows after the sarc header (header + size of header).
Sfat Header
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x4 | u32 | Magic ("SFAT" in big endian) |
| 0x4 | 0x2 | u16 | Size of header (0x14) |
| 0x6 | 0x2 | u16 | File count |
| 0x8 | 0x4 | u32 | Hash seed |
Sfat Entry Array
The sfat entry array follows the sfat header (header + size of header). Array is sized by the sfat header file count, and is sorted by a custom hash derived from the hash seed in the sfat header.
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x4 | u32 | File name hash |
| 0x4 | 0x3 | u24 | File name offset (may be invalid) |
| 0x7 | 0x1 | u8 | Number of file hash collisions |
| 0x8 | 0x4 | u32 | File array start offset |
| 0xc | 0x4 | u32 | File array end offset |
Sfnt Section
Following the sfat section is the sfnt section, a header preceding an array of file path of null-terminated strings.
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x4 | u32 | Magic ("SFAT" in big endian) |
| 0x4 | 0x2 | u16 | Size of header (0x8) |
| 0x6 | 0x2 | u16 | Reserved |