www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/18/17:20:35

From: kagel AT quasar DOT bloomberg DOT com
Date: Tue, 18 Feb 1997 16:55:42 -0500
Message-Id: <9702182155.AA02194@quasar.bloomberg.com >
To: kapieckiel AT harding DOT edu
Cc: djgpp AT delorie DOT com
In-Reply-To: <Pine.SOL.3.94.970216151018.22732B-100000@taz> (kapieckiel@harding.edu)
Subject: Re: File sizes...
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   Errors-To: postmaster AT ns1
   Date: Sun, 16 Feb 1997 15:13:18 -0600 (CST)
   From: "Mr. Fuju" <kapieckiel AT harding DOT edu>
   X-Sender: kapieckiel AT taz
   Mime-Version: 1.0
   Content-Transfer-Encoding: 7BIT
   Content-Type: TEXT/PLAIN; charset=US-ASCII
   Content-Length: 404


   If I use open () to open an existing file, how do I determine the
   filesize?  I am not attaching the file to a stream.  Here is my code:

   ---------------- cut here -------------------

   #include <unistd.h>
   #include <fcntl.h>

   int file1;        // file descriptors
   long filesize;

   void main (void)
   {
      file1 = open ("test.file", O_RDWR | O_CREAT, 0600);

   // filesize is set here...

      close (file1);
   }



Call fstat() if the file is already open and stat() before opening it.  Both
fill a struct stat buffer (to which you have passed a pointer) with file 
descriptive information.

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


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