[physfs] [semi-OT] stdio question
Ryan C. Gordon
icculus at clutteredmind.org
Sun Dec 21 16:38:54 EST 2003
> My assumption is that the seek is deferred until an actual file
> operation, and that it just updates a cursor internally. At least, I
> would seriously hope that's how most implementations work.
I wouldn't assume that...it's likely that many runtimes do a one-to-one
mapping with the system-level API and don't optimize like this...in the
case of seeking, the assumption is frequently "it's file i/o, don't do
it in time-critical code anyhow".
Doubly so because almost every seek is immediately followed by a
read/write, so it's less worth delaying the seek.
That being said, seeking to the end followed by an ftell() is probably
more portable, but you can also use fileno() to get a handle from a
(FILE *) to use with fstat()...on supported platforms, that is, most
platforms, this is probably faster.
--ryan.
More information about the physfs
mailing list