Welcome, Guest. Please login or register.

Author Topic: Costs of Seek()'s  (Read 2623 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Costs of Seek()'s
« on: January 27, 2007, 05:03:02 PM »
Well, it depends. On a lot of factors too, everything from the hardware medium to the filesystem.

In practise, howver, I've found fseek() operations fast for hard drive files of any size when in read mode. I expect its more than likely it simply interrogates the underlying filesystem at the implementation level to find out the size rather than physically looking for the end of the file ;-)

(that's your hint to do the same, btw)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Costs of Seek()'s
« Reply #1 on: January 27, 2007, 06:05:40 PM »
Quote

Piru wrote:
fseek and Seek() are completely different beasts.

dos.library Seek() works on unbuffered files, whereas stdio fseek() works on buffered I/O. However, in this case if you seek to end of file, it's pretty much one and the same.


I know. I was trying to hint that fseek()ing to the very end of the file probably doesn't involve any real IO using Seek(), and that perhaps examining the appropriate FileInfoBlock.fib_Size might be a quick way of working out how big a file is before opening it ;-)
int p; // A