From: Sam Steingold
Subject: truncating files
Date: 
Message-ID: <uln383vn2.fsf@ksp.com>
to use (open file :direction :io :if-exists :overwrite) effectively,
I need to be able to truncate the file (a la truncate(3) in C).
How do I do that?

Thanks.

-- 
Sam Steingold (http://www.podval.org/~sds)
Micros**t is not the answer.  Micros**t is a question, and the answer is Linux,
(http://www.linux.org) the choice of the GNU (http://www.gnu.org) generation.
Daddy, why doesn't this magnet pick up this floppy disk?
From: Rahul Jain
Subject: Re: truncating files
Date: 
Message-ID: <8bu4o9$lqe$1@joe.rice.edu>
In article <·············@ksp.com> posted on Friday, March 24, 2000
3:28 PM, Sam Steingold <···@gnu.org> wrote:
> to use (open file :direction :io :if-exists :overwrite) effectively,
> I need to be able to truncate the file (a la truncate(3) in C).
> How do I do that?
> 
> Thanks.
> 

A simple, naive way would be:
read in N chars into an in-memory buffer (with a loop or whatever)
write that buffer to the file

It might be better to write to a temp file as you're reading and then move
that file over the one you're operating on... but then you have to make sure
that you restore all metadata (e.g. permissions) which can be
implementation/OS specific.

Or, just use your implementations FFI interface to call the truncate function :)

-- 
-> -\-=-=-=-=-=-=-=-=-=-/^\-=-=-=<*><*>=-=-=-/^\-=-=-=-=-=-=-=-=-=-/- <-
-> -/-=-=-=-=-=-=-=-=-=/ {  Rahul -<>- Jain   } \=-=-=-=-=-=-=-=-=-\- <-
-> -\- "I never could get the hang of Thursdays." - HHGTTG by DNA -/- <-
-> -/- http://photino.sid.rice.edu/ -=- ·················@usa.net -\- <-
|--|--------|--------------|----|-------------|------|---------|-----|-|
   Version 11.423.999.210020101.23.50110101.042
   (c)1996-2000, All rights reserved. Disclaimer available upon request.