IO#seek with SEEK_SET

M

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?

martin
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: IO#seek with SEEK_SET"

|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.
 
B

Bertram Scharpf

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top