This trap reads a file header.
Call Parameters | Return Parameters |
D0.B | $47 | D0.L | Error code. |
D1.L | | D1.W | Length of header read. |
D2.L | Buffer length | D2.L | Preserved. |
D3.W | Timeout | D3.L | Preserved. |
A0.L | Channel ID | A0.L | Preserved. |
A1.L | Pointer to buffer | A1.L | Updated. |
ERR_NC | Not complete. |
ERR_NO | Channel not found. |
ERR_BO | Buffer full. |
Address | Length | Contents |
$00 | long | File length |
$04 | byte | File access set to 0 in QDOS v1.03 |
$05 | byte | File type |
$06 | long | Size of data space for executable files |
$0A | long | Unused |
Additionally for Directory Drivers
Address | Length | Contents |
$0E | word | Length of filename |
$10 | 36 bytes | Filename |
$34 | long | Update date |
$38 | word | Version number |
$3A | word | Reserved |
$3C | long | Backup date |
The example below shows how to read the header of an executable file and put its length into D2.L.
Read_h lea -64(a7),a7 ; Space on the stack for the header.
movea.l a7,a1 ; Point to the space.
moveq #64,d2 ; Length of buffer.
moveq #-1,d3 ; Timeout.
moveq #$47,d0 ; FS_HEADR
trap #3 ; Read the header.
tst.l d0 ; OK? . .
bne error ; . . no!
movea.l a7,a1 ; Reset A1
subq.b #1,5(a1) ; Check for executable file
bne error ; OOPS!
move.l (a1),d2 ; Set file length in D2
lea 64(a7),a7 ; Tidy stack
; We could now load the file into memory.