CLOSE :ABORT T on superseding streams
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
Closing a stream opened with :IF-EXISTS :SUPERSEDE with :ABORT T leaves no
file on disk, even if one existed before opening.
The illegality of this is not crystal clear, as the ANSI dictionary
entry for CLOSE says that when :ABORT is T superseded files are not
superseded (ie. the original should be restored), whereas the OPEN
entry says about :IF-EXISTS :SUPERSEDE "If possible, the
implementation should not destroy the old file until the new stream
is closed." -- implying that even though undesirable, early deletion
is legal. Restoring the original would none the less be the polite
thing to do.
Note: Richard Kreuter's "transaction stream" proposal (sbcl-devel link goes here)
would be one way to address this, and other related issues.
description: | updated |
Changed in sbcl: | |
importance: | Undecided → Wishlist |
status: | New → Confirmed |
simple test case (works as expected on ccl and allegro):
(let ((fname "/tmp/a"))
;; touch
(with-open-file (s fname :direction :output :if-exists :supersede)
(format s "hello~%"))
;; supersede
(catch 'hi
(with-open-file (s fname :direction :output :if-exists :supersede)
(format s "hi~%")
(throw 'hi nil)))
;; check still exists
(assert (probe-file fname)) ;; <=== it was deleted:-{
(with-open-file (s fname)
(assert (equal "hello" (read-line s)))
t))