Mail Archives: djgpp-workers/1999/07/21/04:01:44
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.)
- Raw text -