[Implemented] How does FileSeek() work?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] How does FileSeek() work?

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hello all,

How does FileSeek() work? Since you only specify an offset from the
start of the file, does it always seek from the start of the file to
the position you specify? Or would it internally calculate the offset
from the current position? Or would the Windows FS do that for you?
And finally, if nothing ever calculates it as the offset from the
current position, would it be faster to do it like that?

(I ask because I have a program which needs to scan through >120Mb
files, any speed improvement would be nice :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

AFAIK FileSeek() is always ABSOLUTE NOT RELATIVE.
If you have to know how big your file is use 'Lof'.
Your actions must be enclosed by 'while Eof... wend'.
Every time you can determine the current ABSOLUTE position with 'Loc'.
IMHO it is unimportant how big the file is and if you calculate absolute or relative.
But I'm not a pro so I can be wrong with my opinion.
BTW if you need to alter the file you have to add/subtract every byte in your calculation.
Otherwise you get lost. Hope this helps...


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TronDoc.

a relative file position function
would be handy in some circumstances though.
instead of calculating the new offset from the
start of the file, all you would have to do is
FPosFwd(110bytes) or FPosBkd(32bytes)
-or- FPosMov(1000,fwd|bkd) or something...
{I believe PCOM had this feature... -jb}

Edited by - TronDoc on 25 January 2002 16:48:55
Post Reply