#include <stdio.h>
int fsetpos(FILE *stream,
const fpos_t *pos);
int fsetpos64(FILE *stream,
const fpos64_t *pos);
The fsetpos() function repositions a file position
indicator for a stream. The positional information stored in the structure
pointed to by pos must be a value obtained by an earlier call
to fgetpos() on the same stream.
A successful call to fsetpos() clears the end-of-file
indicator for the stream and undoes any effects of ungetc()
on the same stream.
After a fsetpos() call, the next operation on an update
stream may be either input or output.
The fsetpos64() function is identical to the
fsetpos() function except that it is capable of
dealing with disk files that are larger than 2 gigabytes.
The fsetpos64() function is a part of the large
file extensions.
- stream
-
Points to the stream whose file position indicator is to be changed.
- pos
-
Points to a structure that holds positional information.
If successful, the fsetpos() and
fsetpos64() function return zero.
On failure, they return non-zero and errno is set to one of
the following values:
- EAGAIN
-
The O_NONBLOCK flag is set for the file
descriptor underlying stream, and the process
would be delayed in the write operation.
- EBADF
-
The file descriptor underlying stream
is not valid.
- EINTR
-
A signal interrupted the call.
- EINVAL
-
The whence argument is invalid.
- ENOSPC
-
There was no free space
remaining on the device containing the file.
- EPIPE
-
The file underlying stream
is a pipe or a FIFO.
ANSI/ISO 9899-1990.
fsetpos64(): Large File Specification, revision 1.5.
MT-Safe.
If the stream is writable, and there is buffered data which has not yet
been written to the file, fsetpos() and
fsetpos64() cause the unwritten
data to be written before the file position indicator is moved.
The file positions reported by fgetpos(),
ftell(),
or ftello() may be incorrect for files that are
open in text mode in the case that the file is being read, or the
case where the file is being written to and there is buffered
data which has not yet been written to the underlying file. In
the case that the file is being written to, fflush()
can be used prior to calling fgetpos(),
ftell(), ftello()
to ensure the accuracy of these functions.
Text mode files with no buffering do
not have this problem, however performance can be significantly
degraded with buffering turned off.
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
- Functions:
- fgetpos(), fseek(), lseek()
- Miscellaneous:
- lf64
MKS Toolkit 9.2 Documentation Build 16.