seekstream {Rstreams}R Documentation

Set Binary Stream to New Position

Description

Sets a binary stream to a new position.

Usage

  seekstream(stream, offset, origin = "start")

Arguments

stream a previously opened stream.
offset the offset to seek to.
origin the base to which to apply offset.

Details

The origin may be "start", in which case offset is relative to the start of the file, "current", in which case it is relative to the current position, or "end", in which case it is relative to the end of the file.

Value

The new position of the stream.

See Also

openstream

Examples

s <- openstream("mydata", "write")
# Write the bytes from 1 to 100 to the file
writeint(s, 1:100, 1)
# Write the bytes from 1 to 10 to the last 10 bytes of the file
seekstream(s, -10, "end")
writeint(s, 1:10, 1)
closestream(s)
s <- openstream("mydata", "read")
readint(s, 100, 1)
closestream(s)
unlink("mydata")