Mail Archives: djgpp/1997/02/18/17:20:35
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 -