Hi,

"Jim Freeze" <jim / freeze.org> wrote in message
news:20020707235655.A1477 / freeze.org...
> Hi:
>
> How does one determine the eof when using
> sysread. The example below seems to indicate
> that using #eof? corrupts the file pointer.
>
> buff_size = File.stat(ARGV[0]).blksize
> File.open(ARGV[0]) { |f|
> #  until f.eof?  ## this statement corrupts f
>     buff = f.sysread(buff_size)
>     print buff
> #  end
> }
>
How about?

File.open(ARGV[0]) { |f|
while true
  begin
    buff = f.sysread(buff_size)
    print buff
  rescue EOFError
    break
  end
end
}

Or

File.open(ARGV[0]) { |f|
  begin
    while buff = f.sysread(buff_size)
      print buff
    end
  rescue EOFError
  end
}

> Thanks
>
> --
> Jim Freeze
> If only I had something clever to say for my comment...
> ~
>

Park Heesob