Returning to point in file

Hello,

I am opening a file and reading from it. I need to leave the file and
then return to the position that i finished reading at.

OK, so i can get the exact position in bytes using pipe.pos

However when i return to the file i then need to jump back to this
position, i can’t seem to so this using ios.seek, is there a way to do
this?

The final resort i suppose would be to write something to the file to
mark the last position of reading and then when returning read and do
nothing untill you hit this spot… any other ideas?

Thanks, Jamie

On Wed, 20 Dec 2006 23:04:16 +0900, James S. wrote:

The final resort i suppose would be to write something to the file to
mark the last position of reading and then when returning read and do
nothing untill you hit this spot… any other ideas?

Works just fine for me, although I had to seek to 0 to begin with for it
to work.:

irb(main):001:0> f=open("/dev/full",“r”)
=> #<File:/dev/full>
irb(main):002:0> f.read(120)
=> 120 null bytes
irb(main):003:0> f.pos
Errno::EINVAL: Invalid argument - /dev/full
from (irb):3:in `pos’
from (irb):3
from :0
irb(main):005:0> f.seek 400
=> 0
irb(main):006:0> f.pos
=> 400
irb(main):007:0> f.seek 0
=> 0
irb(main):008:0> f.read 120
=> 120 null bytes
irb(main):009:0> f.pos
=> 120