delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/11/05:42:35

To: dnelson AT quake DOT xnet DOT com (Dan Nelson)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (djgpp)
Subject: Re: filesize() equivalent?
Date: Sun, 11 Dec 94 11:59:09 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>

> This is probably a FAQ somewhere, but what IS the preferred way to find
> filesize?  lseek() to EOF, or a fstat() call?  The Borland version of
> fstat() does the seek() internally.  So for Borland (and therefore, this
> version of gcc), lseek() seems to be better.

The version of fstat() in libc.a which comes with DJGPP 1.12m2
does a terrible job.  This isn't a DJGPP's problem, its fstat()
just jumps to the go32 extender which calls fstat() from the
Turbo C library.  The file's size is about the only thing it
brings correctly, though.

Take a look at the version I've written (ftp://omnigate.clarkson.edu:
/pub/msdos/djgpp/pub/djstat02.zip).  It also includes a separate function
named filelength() which does exactly what its Borland's namesake does.

Btw, seek() and lseek() are the same under DOS, AFAIK.

- Raw text -


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