Lseekposition in filelseekint pnlong positionint typeAssembler Equivalent
os9 I$SEEK
Description
The read or write pointer for the open file with the path
number, "pn", is positioned by lseek to the specified place in
the file. The "type" indicates from where "position" is to be
measured: if 0, from the beginning of the file, if 1, from the
current location, or if 2, from the end of the file.
Seeking to a location beyond the end of a file open for
writing and then writing to it, creates a "hole" in the file
which appears to be filled with zeros from the previous end to
the position sought.
The returned value is the resulting position in the file unless
there is an error, so to find out the current position use
lseek(pn,0l,1);
Caveats
The argument "position" must be a long integer. Constants
should be explicitly made long by appending an "l", as above,
and other types should be converted using a cast:
e.g. lseek(pn,(long)pos,1);
Notice also, that the return value from lseek is itself a long integer.
Diagnostics
-1 is returned if "pn" is a bad path number, or attempting to
seek to a position before the beginning of a file.
See Also
creat(),
open(),
Standard Library function
"fseek"