FSEEK(3F)FSEEK(3F)NAME
fseek, fseeko64, ftell, ftello64 - reposition a file on a logical unit
SYNOPSIS
integer*4 function fseek (lunit, offset, from)
integer*4 lunit
integer*4 offset
integer*8 offset in 64-bit environments
integer*4 from
integer*4 function fseeko64 (lunit, offset, from)
integer*4 lunit
integer*8 offset
integer*4 from
integer*4 function ftell (lunit)
integer*4 lunit
integer*8 function ftello64 (lunit)
integer*4 lunit
DESCRIPTION
lunit must refer to an open logical unit. offset is an offset in bytes
relative to the position specified by from. Valid values for from are:
0 meaning 'beginning of the file'
1 meaning 'the current position'
2 meaning 'the end of the file'
The value returned by fseek is 0 if successful, a system error code
otherwise. See perror(3F).
The function ftell returns the current position of the file associated
with the specified logical unit. The value is an offset, in bytes,
from the beginning of the file. If the value returned is negative, it
indicates an error and is the negation of the system error code. See
perror(3F).
The offset returned by ftell can be used by fseek at a later time in
the program to reposition the file to that same place for reading.
CAUTION: On sequential files, following a call to fseek by an output
operation (e.g. WRITE) causes all data records following the new posi‐
tion to be deleted and replaced by the new data record (and an end-of-
file mark). Rewriting a record in place can only be done with direct
access files.
fseeko64 and ftello64 operate identically to fseek and ftell respec‐
tively, except that the first two routines will operate on "large
files" as well -- files with size in bytes greater than the range of
INTEGER*4 data (2 Gb). Large file support was introduced with the
Solaris 2.6 operating environment.
When used with a large file, the variable receiving the result from
ftello64 must also be declared INTEGER*8 to avoid truncation.
NOTES
When compiled to run in a 64-bit environment (with the compiler option
-xarch=v9 or v9a) the offset variable passed to fseek must be declared
INTEGER*8.
The 64-bit versions, fseeko64 and ftello64, are provided to make
portability between 32-bit and 64-bit environments easier.
FILES
libfui.a
SEE ALSOfseek(3S), perror(3F),
03/02/25 FSEEK(3F)