NAME

zkFseek - reposition a file-position indicator in a stream

SYNOPSIS

#include "zkStdio.h"

int zkFseek(FILE* stream, long int offset, int whence);

DESCRIPTION

The zkFseek() function sets the file-position indicator for the stream pointed to by stream.

The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence. The specified point is the beginning of the file for SEEK_SET, the current value of the file-position indicator for SEEK_CUR, or end-of-file for SEEK_END.

A successful call to zkFseek() clears the end-of-file indicator for the stream and undoes any effects of ungetc() on the same stream. After an zkFseek() call, the next operation on an update stream may be either input or output.

If the most recent operation, other than zkFtell(), on a given stream is zkFflush(), the file offset in the underlying open file description will be adjusted to reflect the location specified by zkFseek().

The zkFseek() function allows the file-position indicator to be set beyond the end of existing data in the file. If data is later written at this point, subsequent reads of data in the gap will return bytes with the value 0 until data is actually written into the gap.

The behaviour of zkFseek() on devices which are incapable of seeking is implementation-dependent. The value of the file offset associated with such a device is undefined.

If the stream is writable and buffered data had not been written to the underlying file, zkFseek() will cause the unwritten data to be written to the file.

In a locale with state-dependent encoding, whether zkFseek() restores the stream's shift state is implementation-dependent.

RETURN VALUE

The zkFseek() functions return 0 if they succeed; otherwise they return -1 and set errno to indicate the error.

ERRORS

The zkFseek() functions will fail if, either the stream is unbuffered or the stream's buffer needed to be flushed, and the call to zkFseek() causes an underlying writing I/O function to be invoked:

[EAGAIN]
The O_NONBLOCK flag is set for the file descriptor and the process would be delayed in the write operation.
[EBADF]
The file descriptor underlying the stream file is not open for writing or the stream's buffer needed to be flushed and the file is not open.
[EFBIG]
An attempt was made to write a file that exceeds the maximum file size  or the process' file size limit.
[EFBIG]
The file is a regular file and an attempt was made to write at or beyond the offset maximum associated with the corresponding stream.
[EINTR]
The write operation was terminated due to the receipt of a signal, and no data was transferred.
[EINVAL]
The whence argument is invalid. The resulting file-position indicator would be set to a negative value.
[EIO]
A physical I/O error has occurred, or  the process is a member of a background process group attempting to perform a write() to its controlling terminal, TOSTOP is set, the process is neither ignoring nor blocking SIGTTOU and the process group of the process is orphaned. This error may also be returned under implementation-dependent conditions.
[ENOSPC]
There was no free space remaining on the device containing the file.
[EOVERFLOW]
The resulting file offset would be a value which cannot be represented correctly in an object of type long.
[EPIPE]
The file descriptor underlying stream is associated with a pipe or FIFO.
[EPIPE]
An attempt was made to write to a pipe or FIFO that is not open for reading by any process; a SIGPIPE signal will also be sent to the thread.
[ENXIO]
A request was made of a non-existent device, or the request was outside the capabilities of the device.