delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/01/05:26:56

Date: Wed, 1 Nov 2000 10:23:24 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp AT delorie DOT com
Subject: Re: filelength(): POSIX or not
In-Reply-To: <8tn4em$m65$1@nets3.rz.RWTH-Aachen.DE>
Message-ID: <Pine.SUN.3.91.1001101102224.7517E@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019