www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/13/10:51:11

From: "Chris A. Triebel" <cat AT sun4 DOT iol DOT unh DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: I'd like to truncate a file but I don't know how
Date: Mon, 10 Feb 1997 12:13:05 -0500
Organization: University of New Hampshire - Durham, NH
Lines: 33
Message-ID: <Pine.SUN.3.91.970210121009.24187A-100000@sun4.iol.unh.edu>
References: <rkg1z4ahec DOT fsf AT taz DOT dra DOT hmg DOT gb>
NNTP-Posting-Host: sun4.iol.unh.edu
Mime-Version: 1.0
In-Reply-To: <rkg1z4ahec.fsf@taz.dra.hmg.gb>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 10 Feb 1997, Ian Miller wrote:

> Date: 10 FEB 1997 14:02:19 +0000 
> From: Ian Miller <itmiller AT dra DOT hmg DOT gb>
> Newgroups: comp.os.msdos.djgpp
> Subject: I'd like to truncate a file but I don't know how 
> 
> I'd like to say "truncate this file here" in one of my programs.
> 
> Can I/how do I do this with standard C/C++?
> Can I/how do I do this with non-standard features of DJGPP C/C++?
> 
> At the moment, if I delete a word from a file (a dictionary file
> as it happens) and shift everything down to reclaim the space,
> I'm left with a load of spare space at the end that I can't get
> rid of.
> 
> TIA,
> -- 
> Ian Miller, Dorset, UK
> DJGPP 2.01, Win95 DOS box (LFN undefined, FNCASE=y)
> 


I don't know if this is a viable option for you, but what about importing 
the entire file into memory, making changes, edits, and accesses from 
local memory rather than from the file itself.  Then you can close the 
file, open it with O_WRITE|O_TRUNC ( I think ) to purge the file and 
write your new information out.  Of course that removes the possibility 
of making a backup which you might want to do.

cat

- Raw text -


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