Home Contents | # rawio:seek | Rawio | Core4 Lua Event System

## SYNOPSIS

#include <lua/unistd.lh>

1. offset = handle:seek(offset, whence)
2. offset = handle:tell()

## DESCRIPTION

rawio:seek() moves the offset of the file pointer according to the directive whence as follows:

SEEK_SET or "set" | The offset is set to offset bytes.
SEEK_CUR or "cur" | The offset is set to the current location plus offset bytes.
SEEK_END or "end" | The offset is set to the length of the file plus offset bytes.

rawio:tell() is used to read the current file position. It is synonymous to rawio:seek(0, SEEK_CUR).

## RETURN VALUE

On success, returns the file offset after the command has completed. On failure, returns nil. In case of an error, the error can be retrieved using rawio:lastError().

## EXAMPLE

> > > > > >
handle = rawio.open("/tmp/test.txt", rawio.rdwr | rawio.creat) print(handle:tell()) handle:write("HUllo World!") print(handle:seek(1, "set")) handle:write("e") print(handle:tell())
0 1 2

## SEE ALSO

rawio.attach, rawio:blocking, rawio:canReadLine, rawio:clearError, rawio:close, rawio:connect, rawio:detach, rawio:lastError, rawio:line, rawio:lines, rawio.access, rawio.open, rawio:read, rawio:copy, rawio.stat, rawio.statfs, rawio:writet, rawio:write