[wplug] off topic.... C programming question

Coutch, Robert Robert.Coutch at tvratings.com
Tue Mar 11 16:25:39 EST 2003


You might want to consider this.

Count the number of bytes copied as you go and
exit when a certian preset limit ( or maximum free space) has been reached
to avoid
a runaway condition.

-Bob

-----Original Message-----
From: R.E.Coutch [mailto:coutchre at usaor.net]
Sent: Tuesday, March 11, 2003 3:10 PM
To: coutchre at tvratings.com
Subject: Re: [wplug] off topic.... C programming question


On Mon, Mar 10, 2003 at 05:41:14PM -0500, Sal Mangiapane wrote:
> Hi all,
> 
> I am attempting to write a command line C program that will receive an
> input file that it will process in the format:
> 
> cat input.file | my-C-program > output.file

Note that this is the same as: my-C-program < input.file > output.file

> 
> Can I tell the size of the input.file prior to processing?  Or do I
> have to read in the whole input.file and calculate it myself? 

Consider if the "file" being piped in is not a normal file.  ie.

cat /dev/zero | my-C-program

How can you tell the size of this beforehand?

(Sure you can! Infinity!)

If you want to obtain file size information you need to investigate the
stat() family of functions.

-- 
; Matthew Danish <mdanish at andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."
_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug



More information about the wplug mailing list