delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/04/10:46:47

Date: Thu, 4 Sep 1997 10:44:36 -0400 (EDT)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
To: Luke Steele <luke DOT steele AT bigfoot DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: Determining size of file.
In-Reply-To: <340dbe08.2566192@news.cableinet.net>
Message-Id: <Pine.D-G.3.91.970904104232.16661B-100000@dg1>
Mime-Version: 1.0

On Wed, 3 Sep 1997, Luke Steele wrote:

> Hi,
> 
> I'm trying to convert a program I've written under DJGPP to run in a
> UNIX enviroment using the gcc compiler.  I thought there would be few
> difficulties, but in fact I'm encountering quite a few, one of which
> involves determining the size of a file.  At the moment I'm using the
> filelength function, but the UNIX compiler doesn't seem to support
> this function.
> 
> Does anyone know a (reasonably fast) way of determining the size of a
> file under UNIX?
> 
> I'd be grateful for any help with this problem!  (And appologies if
> I've posted this message to the wrong group, but it seemed my best
> chance of getting a knowledgable answer!)

Check out the stat() anf fstat() functions.  One if for an open file
identified by a file descriptor (if you used fopen() you can get the
file descriptor by calling fileno((FILE *))), the other takes a path. 

Art S. Kagel, kagel AT bloomberg DOT com

- Raw text -


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