User`s guide

BDOS FUNCTION 35: COMPUTE FILE SIZE
Entry Parameters:
Registers C: 23H
DE: FCB Address
Returned Value:
Registers A: Error Flag
H: Physical or Extended error
Random Record Field Set
The Compute File Size function determines the virtual file size, which is, in effect,
the address of the record immediately following the end of the file. The virtual size
of a file corresponds to the physical size if the file is written sequentially. If the file is
written in random mode, gaps might exist in the allocation, and the file might con-
tain fewer records than the indicated size. For example, if a single record with record
number 262,143, the CP/M 3 maximum is written to a file using the Write Random
function, then the virtual size of the file is 262,144 records even though only 1 data
block 'is actually allocated.
To compute file size, the calling program passes in register pair DE the address of
an FCB in random mode format, bytes rO, rl and r2 present. Note that the FCB
must contain an unambiguous filename and filetype. Function 35 sets the random
record field of the FCB to the random record number + 1 of the last record in the
file. If the r2 byte is set to 04, then the file contains the maximum record count
262,144.
A program can append data to the end of an existing file by calling Function 35 to
set the random record position to the end of file, and then performing a sequence of
random writes starting at the preset record address.
Note: the BDOS does not require that the file be open to use Function 35. However,
if the file has been written to, it must be closed before calling Function 35. Other-
wise, an incorrect file size might be returned.
3-53
BDOS Function Calls CP/M 3 Programmers Guide