<< Previous | Next >>

fseek (FS2)

int fseek( File * f, long where, char whence );

Description

Set the current read/write position of the file. Bytes in a file are sequentially numbered starting at zero. If the current position is zero, then the first byte of the file will be read or written. If the position equals the file length, then no data can be read, but any write will append data to the file.

fseek() allows the position to be set relative to the start or end of the file, or relative to its current position.

In the special case of SEEK_RAW, an unspecified number of bytes beyond the known end-of- file may be readable. The actual amount depends on the amount of space left in the last internal block of the file. This mode only applies to reading, and is provided for the purpose of data recovery in the case that the application knows more about the file structure than the filesystem.

Parameters

f
Pointer to file descriptor (initialized by fopen_rd(), fopen_wr() or fcreate()).

where
New position, or offset.

whence
One of the following values:

SEEK_SET: 'where' (non-negative only) is relative to start of file.
SEEK_CUR: 'where' (positive or negative) is relative to the current position.
SEEK_END: 'where' (non-positive only) is relative to the end of the file.
SEEK_RAW: Similar to SEEK_END, except the file descriptor is set in a special mode which allows reading beyond the end of the file.


Return value

 0: Success.

!0: The computed position was outside of the current file contents, and has been adjusted to the nearest valid position.

ERRNO values

None.

Library

FS2.LIB

See also

ftell (FS2), fread (FS2), fwrite (FS2)


Dynamic C Functions << Previous | Next >> rabbit.com