Re: Why doesn't (open ... :if-exists) support :truncate?



On 2007-11-30, Richard M Kreuter <kreuter@xxxxxxxxx> wrote:
Well, the CLHS entry for OPEN says that when :IF-EXISTS is :SUPERSEDE,
"a new file with the same name as the old one is created". ISTM that
there's some difference between truncating a file and replacing one
file with another (using something like POSIX rename(), say):

Indeed. I was quite stumped when my SBCL heap got corrupted while
writing new files using :SUPERSEDE -- I had those files mmap()ed into
dynamic space... :-) Of course, it is useful to have an
implementation-specific way to do O_TRUNC integrated into OPEN, but
:SUPERSEDE should not be it.

SBCL's :APPEND has a similar bug. The spec says "The file pointer is
initially positioned at the end of the file", but SBCL maps it to
O_APPEND instead.


d.
.