seekstream {Rstreams} | R Documentation |
Sets a binary stream to a new position.
seekstream(stream, offset, origin = "start")
stream |
a previously opened stream. |
offset |
the offset to seek to. |
origin |
the base to which to apply offset. |
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.
The new position of the stream.
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")