delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/13/00:53:21

Date: Mon, 12 Dec 94 20:21 MST
From: mat AT ardi DOT com (Mat Hostetter)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Cc: IBBT0 AT cc DOT uab DOT es
Subject: Re: Help about truncating files
References: <01HKK6FUXGXU8WZEM3 AT cc DOT uab DOT es>
<9412121810 DOT AA25037 AT delorie>

>>>>> "dj" == DJ Delorie <dj AT stealth DOT ctron DOT com> writes:

    dj> DOS says that if you write zero bytes, the file is truncated
    dj> where the pointer is.  With FILE* streams, this is tricky
    dj> (because of the caching), but what you can do is this:

    dj> fflush(f);
    dj> lseek(fileno(f), POS, 0);
    dj> write(fileno(f), 0, 0);

ftruncate() in the djgpp C library does exactly this, but without the
fflush().

-Mat

- Raw text -


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