DOS Fn 42H: Set File Pointer
Expects: AH 42H
BX file handle
CX:DX distance to move file pointer: offset is (CX * 65536) + DX
AL subfn: 0 = move pointer to start of file + CX:DX
1 = move pointer to current position + CX:DX
2 = move pointer to end of file + CX:DX
Returns: AX error code if CF is set to CY
DX:AX new position of file read/write pointer (if no error)
Info: This moves the logical read/write pointer to the desired address.
All file reads and writes will start from the new address.
Notes: ■ One way to obtain the size of a file is to call with AL=2,
CX=0, DX=0 (the length is returned in DX:AX --DX is the most
significant word--actual length is (DX * 65536) + AX.
A faster way is to use fn 4eH (find file).
■ To truncate a file, use LSEEK to move to the desired position,
and use Fn 40H with CX=0.
■ To pre-allocate disk space to a file, use LSEEK to move to the
desired file length, then use Fn 40H with CX=0. Then close the
file (Fn 3eH).
(!) When you use this technique on a DoubleSpace compressed
drive, DoubleSpace does not actually allocate disk storage from
the physical medium. It considers these bytes to be
"infinitely compressible". See MDFAT.
See Also: Handle-Oriented File I/O