equivalent of fseek?

111 views
Skip to first unread message

Rajn

unread,
Nov 28, 2015, 1:00:14 PM11/28/15
to julia-users
Is there an fseek in Julia which returns to an offset from the beginning of the buffer during a binary file read?
Would seekstart followed by seek or skip work? I understand that stream is not the same as file in read()?
Thanks

James Gilbert

unread,
Nov 29, 2015, 4:38:11 AM11/29/15
to julia-users
I believe that in seek(s, pos), pos is the absolute position from the start of the stream, and in skip(s, offset), offset is relative to the current position.

A "stream" can be any IO type, such as a file on disk or an IOBuffer in memory.

Rajn

unread,
Nov 29, 2015, 10:41:00 PM11/29/15
to julia-users
Thanks James for pointing it out. It did work.
Is there a need for a C++ like function fseek in that case at all?

Stefan Karpinski

unread,
Nov 30, 2015, 9:55:15 AM11/30/15
to Julia Users
No, seek does what the clib fseek function does. The only reason fseek starts with an "f" is because it belongs to the family of higher level file operations that all start with "f" – fopen, fclose, etc.
Reply all
Reply to author
Forward
0 new messages