Re: Why doesn't (open ... :if-exists) support :truncate?
- From: Richard M Kreuter <kreuter@xxxxxxxxx>
- Date: Fri, 30 Nov 2007 19:20:52 GMT
David Lichteblau <usenet-2006@xxxxxxxxxxxxxx> writes:
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.
Well clearly the file pointer is supposed to be positioned to the end
of the file, but I don't see anything that says that says the
implementation is forbidden from opening the file with O_APPEND-y
semantics, only that the file is destructively modified.
(Also, if you're interested in being able to do random-access writes,
doing and starting at the end of the file, I would expect this to do
the trick on Unix file systems:
(with-open-file (stream pathname :direction :overwrite)
(file-position stream :end)
... stuff ...)
This might not work on some other file systems though. For example,
while the Unix file system ensures that when you lseek to or past the
end of a file and then do some writing, the file will automatically be
resized (possibly sparsely), I think I've read that some older file
systems required you to manually allocate space for files; anyway you
can imagine a file system like that. Maybe a CL implementation that
talked to such a file system would constrain :OVERWRITE to not resize
the file, but have :APPEND do the resizing implicitly.)
--
.
- References:
- Why doesn't (open ... :if-exists) support :truncate?
- From: Richard M Kreuter
- Re: Why doesn't (open ... :if-exists) support :truncate?
- From: Steven M. Haflich
- Re: Why doesn't (open ... :if-exists) support :truncate?
- From: Richard M Kreuter
- Re: Why doesn't (open ... :if-exists) support :truncate?
- From: David Lichteblau
- Why doesn't (open ... :if-exists) support :truncate?
- Prev by Date: Re: A simple debugging macro
- Next by Date: Re: Toronto Lisp User Group?
- Previous by thread: Re: Why doesn't (open ... :if-exists) support :truncate?
- Next by thread: Re: Why doesn't (open ... :if-exists) support :truncate?
- Index(es):
Relevant Pages
|