delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/11/23:01:36

Date: Fri, 12 Dec 1997 11:54:34 +0800 (PST)
From: Orlando Andico <orly AT dilnet DOT upd DOT edu DOT ph>
To: Mark Favata <favata AT epix DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Error Writing to File
In-Reply-To: <348EFB98.25F8@epix.net>
Message-ID: <Pine.LNX.3.95.971212115323.29506A-100000@jewel.eee.upd.edu.ph>
MIME-Version: 1.0

On Wed, 10 Dec 1997, Mark Favata wrote:

> Can someone please help me.  I am writing an encryption program and
> want to add a file wipe feature.  I plan on overwriting the file with 1,
> then 2, etc.  The problem is, it keeps writing past the eof mark. 
> Within about 2 seconds it has already written 2 megs to the file.  My
> code doesn't seem to stop for the EOF.  Can you tell me what is wrong
> with my code?
..
better idea: use stat(2) to determine the file's length (read the Info
docs for details) so you don't have to rely on feof() or similar. Also, if
you know the length in advance, you can fwrite() your buffer to the file
in 8K chunks, which is very fast.


- Raw text -


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