LSEEK - reposition read/write pointer.

(Compatible with UNIX System V C)

Usage:

#include <fildes.h>
long lseek();
ret = lseek( fd, offset, begin );

Where:

int fd;
is a valid file descriptor as returned by "open" or "creat".
long offset;
gives the offset of the desired position (in bytes).
int begin;
indicates where to begin repositioning. If "begin" is 0, the pointer is set to "offset" bytes from the beginning of the file. If "begin" is 1, the pointer is set to "offset" bytes from the current location in the file. If "begin" is 2, the pointer is set to "offset" bytes beyond the current end of the file.
long ret;
is the new offset of the pointer (in bytes) from the beginning of the file. If the operation failed, a -1 is returned and the library variable "errno" is set to indicate the error (see below).

Description:

"lseek" moves the read/write file pointer inside a given file. Note that seeking is not permitted on some devices; in such cases, the value of the file pointer is undefined.

Possible Errors:

errno=EBADF
the "fd" value was invalid.
errno=EINVAL
"begin" was invalid, or any other failure.

See Also:

expl c lib errno

expl c include fildes

Copyright 1996, Thinkage Ltd.