Mail Archives: djgpp/1997/04/21/03:15:32
On Fri, 18 Apr 1997, Fred Smith wrote:
> Try doing:
>
> fflush (fp);
>
> BEFORE the filelength call.
AFAIK, this is incorrect. A call to `fflush' indeed flushes buffers,
but it doesn't force DOS to update the file's directory entry (which
includes the size). That's because `fflush' only flushes the DJGPP's
buffers; DOS also buffers file I/O, even if you don't have a disk
cache, and those buffers internal to DOS aren't flushed.
A call to `fsync' is required to update the file on disk and its
directory entry, if closing the file is undesirable. But the easiest
solution (IMHO) is just to use `fseek'.
- Raw text -