On Aug 28, 7:37=A0pm, "Heesob Park" <pha... / gmail.com> wrote:
> 2008/8/26 Daniel Berger <djber... / gmail.com>:
>
> > On Aug 25, 7:59 pm, "Heesob Park" <pha... / gmail.com> wrote:
> >> Hi,
>
> >> 2008/8/26 Daniel Berger <djber... / gmail.com>:
>
> <snip>>
> >> I guess you should use lseek and read combination.
>
> > Ruby has no lseek that I'm aware of. I tried an open + seek + read
> > approach, but I get the same result.
>
> Are you unaware IO#sysseek ? sysseek is actualy lseek.
>
> ------------------------------------------------------------- IO#sysseek
> =A0 =A0 =A0ios.sysseek(offset, whence=3DSEEK_SET) =A0 =3D> integer
> ------------------------------------------------------------------------
> =A0 =A0 =A0Seeks to a given _offset_ in the stream according to the value=
 of
> =A0 =A0 =A0_whence_ (see +IO#seek+ for values of _whence_). Returns the n=
ew
> =A0 =A0 =A0offset into the file.
>
> =A0 =A0 =A0 =A0 f =3D File.new("testfile")
> =A0 =A0 =A0 =A0 f.sysseek(-13, IO::SEEK_END) =A0 #=3D> 53
> =A0 =A0 =A0 =A0 f.sysread(10) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#=3D> "A=
nd so on."
>
> I guess open + sysseek +sysread will work for you.

I tried sysseek on RHEL, but couldn't make it work. It's possible I
did something wrong, but I'm not sure what.

I also see nothing in the lseek or sysseek documentation that says it
doesn't move the file pointer.

Regards,

Dan