Moves the file pointer to a location specified as an offset from the origin in a file.
#include <unistd.h> off_t lseek (int handle, off_t offset, int origin); long64 _lseek64 (int handle, long64 offset, int origin);
handle
offset
Value | Description |
---|---|
SEEK_SET | Beginning of file. |
SEEK_CUR | Current position of file pointer. |
SEEK_END | End of file. |
origin |
Initial position. |
The next operation on the file occurs at the new location.
lseek can reposition the pointer anywhere in a file and beyond the end of the file. An attempt to position the pointer before the beginning of the file causes an error.
Results are undefined on devices incapable of seeking, like terminals and printers.
EBADF | Invalid file descriptor. |
EINVAL | Invalid value for origin, or position specified by offset is before the beginning of the file. |
EIMPL | Library call is not implemented in the current configuration |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/io.h | unistd.h | clib.lib |