delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/23/15:55:28

Message-ID: <3798C905.8BD03677@pmail.net>
Date: Fri, 23 Jul 1999 21:56:53 +0200
From: Fredrick Backman <fredrick DOT backman AT pmail DOT net>
X-Mailer: Mozilla 4.6 [en] (Win98; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: file size
References: <99072310052600 DOT 01111 AT dome DOT calderathin DOT com>
Reply-To: djgpp AT delorie DOT com

Greetings Darren,

Try the C system call stat() which not only gives you the file size but
also when the file was last modified etc. It takes two arguments: a
string (the filename) and the address to a structure (struct stat *).
The structure field you want is called st_size, which gives the size in
bytes.  Example:

struct stat statbuf;

stat("hello.dat", &statbuf);
printf("The size of hello.dat is %d\n", statbuf.st_size);


Hope that works :-)

I know stat() gives more info if you use it on a UNIX system, and I
haven't honestly tried it myself in DOS but I can't see why it shouldn't
work (some fields in the structure will be useless in DOS but don't
worry about that now).

cheers
Fred

Darren Noble wrote:

> Does anyone know how to get the size of a file in DJGPP?
>
> --
> Linux Rules
>
> Darren 'The' Noble

--
Fred Backman
Lead Wizard
Binary Spells
http://www.femmefetish.com/games/


- Raw text -


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