Seedling, sapling and tree
A file's directory entry gives its key block and its length (end of file, in bytes). What the key block is depends on the storage type:
| Storage type | File size | The key block | Blocks used |
|---|---|---|---|
| 1 seedling | up to 512 bytes | The data itself | 1 |
| 2 sapling | up to 128 KB (256 blocks) | An index block listing the data blocks | 1 + data blocks |
| 3 tree | up to 16 MB | A master index block listing up to 128 index blocks, each of 256 data blocks | 1 + index blocks + data blocks |
Index blocks
An index block holds 256 block numbers, but not side by side: the low bytes of all 256 are in its first 256 bytes and the high bytes in its last 256. Entry i is byte i plus 256 × byte i + 256. Entry 0 is the first 512 bytes of the file, entry 1 the next, and so on; a block number of 0 is a hole (a sparse file never wrote that part, and it reads as zeros). The end of file says how many entries are in use: the rest of the index is zero.
The viewer reads the entries up to the end of file and lists the index blocks and data blocks by file name in the tree. It also checks the entry's "blocks used" against the number of index blocks and data blocks found (a sparse file uses fewer blocks than its length suggests) and reports a file whose count disagrees, a data block outside the volume, and a block two files claim.
Extended files (GS/OS)
Storage type 5 is a file with a data fork and a resource fork. Its key block holds two small entries of eight bytes, for the data fork at offset 0 and the resource fork at offset 256: a storage type, a key block, a block count and a 3-byte end of file. This layout is from memory of the ProDOS technical notes; no extended file was available to check it, and the viewer lists such a file but does not read the forks.
What opens
| File type | Opens as |
|---|---|
BAS $FC | Applesoft BASIC listing; no length is stored before the program |
INT $FA | Integer BASIC listing |
BIN $06, SYS $FF, CMD $F0 | Machine code from the aux type as the load address |
TXT $04 | Text, high bit removed, carriage returns as line ends; the raw bytes are one click away |
| anything else | The bytes of the file |