Mail Archives: djgpp/2000/11/01/05:26:56
On 31 Oct 2000, Hans-Bernhard Broeker wrote:
> [ISO-C 89:7.9.9.2#2, C99 draft 7.19.9.2#2]:
>
> A binary stream
> need not meaningfully support fseek calls with a whence
> value of SEEK_END.
To put this in a practical perspective, this does work in DJGPP.
> It's long-standing knowledge in the C newsgroups there is, in fact, no
> way at all to portably find the length of a given file other than
> reading all of it and adding the byte counts.
By ``portable'' you probably mean ANSI-portable. Because Posix does
have a portable way: stat/fstat.
Anyway, the validity of the above assertion depends on the definition
of ``length of a file''. On systems where fseek doesn't work well
with SEEK_END, this definition (or, more accurately, the intended use
of file's length in the program) is very important. For some
definitions, even reading the file and counting bytes won't yield a
meaningful result.
- Raw text -