[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

IO#seek with SEEK_SET

Martin DeMello

2/19/2005 10:35:00 AM

Does calling IO#seek on a file with the SEEK_SET option internally do
something efficient if the position I want to seek to is ahead of the
current position? Or does it always do a rewind and then seek?

martin
3 Answers

Yukihiro Matsumoto

2/19/2005 12:23:00 PM

0

Hi,

In message "Re: IO#seek with SEEK_SET"
on Sat, 19 Feb 2005 19:39:44 +0900, Martin DeMello <martindemello@yahoo.com> writes:

|Does calling IO#seek on a file with the SEEK_SET option internally do
|something efficient if the position I want to seek to is ahead of the
|current position? Or does it always do a rewind and then seek?

It uses fseek(3) internally, so it's probably doing "something
efficient", rather than "rewind then seek".

matz.


Bertram Scharpf

2/19/2005 12:39:00 PM

0

Hi,

Am Samstag, 19. Feb 2005, 19:39:44 +0900 schrieb Martin DeMello:
> Does calling IO#seek on a file with the SEEK_SET option internally do
> something efficient if the position I want to seek to is ahead of the
> current position? Or does it always do a rewind and then seek?

That depends on what you operation system's `lseek' call
does.

I would be wondering if the hard disks read head
moved the way you describe.

Bertram

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...


Martin DeMello

2/19/2005 8:42:00 PM

0

Bertram Scharpf <lists@bertram-scharpf.de> wrote:
>
> I would be wondering if the hard disks read head
> moved the way you describe.

Good point.

martin