Skip to content

Files

Latest commit

5b48d2c · Jun 15, 2024

History

History
49 lines (35 loc) · 2.33 KB

NOTES.md

File metadata and controls

49 lines (35 loc) · 2.33 KB

Notes

File format

All numbers are little-endian unsigned ints.

The file is constructed by concatenating each of the following sections in sequence.

Header

Offset Size Value
0 16 "PinEightGBFS\r\n\x1a\n"
16 4 Total GBFS file size
20 2 Offset to start of directory (always 32)
22 2 Number of objects in GBFS file
24 8 Reserved

Directory entries

Repeats once for each object in the GBFS file.

Offset Size Value
0 24 Object name (may not be null-terminated)
24 4 Size of object
28 4 File offset to start of object

Extra padding may be observed at the end of the directory, but before the objects start. This may be the "wasted space" referred to in the original gbfs tool.

Objects

Objects are concatenated directly to the GBFS file, one after another.

The original GBFS tool pads each file to a 16-byte boundary. It does not seem this is necessary for libgbfs to function correctly.

File build dependencies

  • The header needs to know the total GBFS file size.
    • The header is always 32 bytes.
    • The size of the directory section must be 32 bytes times the number of objects in the GBFS file.
    • The size of the objects section is the sum of all object sizes.
  • The header needs to know the number of objects in the GBFS file.
    • The number of objects should be determinable up front.
  • Each directory entry needs to know the size of its object.
    • The size of each object should be determinable up front.
  • Each directory entry needs to know the offset to the start of its object.
    • The header knows the size of the directory entries section. Objects start at 32 (the fixed size of the header) plus this.
    • The size of any previous object is added to get the starting offset for the current entry's object.