Date: Wed, 21 Jul 1999 10:59:20 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Alain Magloire cc: djgpp-workers AT delorie DOT com Subject: Re: ftruncate In-Reply-To: <199907201418.KAA23375@mccoy2.ECE.McGill.CA> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 20 Jul 1999, Alain Magloire wrote: > I'm not sure I follow, so you are saying if I want to shrink a file, > I can do that by lseek()ing back and write() 0 byte ? Yes. But it's not a 0 byte, it's zero bytes. That is, you tell DOS to write zero bytes to the file. Instead of interpreting this as a no-op, DOS shrinks the file's size to the current file pointer position. Amazingly enough, it's not a bug, it's a feature ;-). > To do this on Un*x I got to use ftruncate(); I know. But DOS doesn't have a special system call for that, so DJGPP uses the seek/write-zero way to emulate it. (Now it also seeks back before returning.)