Update of /cvsroot/sbcl/sbcl/src/code
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11196/src/code
Modified Files:
filesys.lisp
Log Message:
1.0.30.22: better DELETE-FILE on streams
* Don't close the stream on Unix, so users can enjoy the normal
Unixy-IO to unlinked files.
* On Windows, close the stream with :ABORT NIL, so that there
is no danger of close trying to delete file as well.
Bug with DELETE-FILE trying to delete files twice reported by
John Fremlin.
Index: filesys.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/filesys.lisp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- filesys.lisp 21 Jun 2009 21:59:23 -0000 1.86
+++ filesys.lisp 31 Jul 2009 09:11:16 -0000 1.87
@@ -471,17 +471,17 @@
(defun delete-file (file)
#!+sb-doc
- "Delete the specified FILE."
- (let* ((truename (probe-file file))
- (namestring (when truename
- (native-namestring truename :as-file t))))
+ "Delete the specified FILE.
+
+If FILE is a stream, on Windows the stream is closed immediately. On Unix
+plaforms the stream remains open, allowing IO to continue: the OS resources
+associated with the deleted file remain available till the stream is closed as
+per standard Unix unlink() behaviour."
+ (let* ((truename (truename file))
+ (namestring (native-namestring truename :as-file t)))
+ #!+win32
(when (streamp file)
- (close file :abort t))
- (unless namestring
- (error 'simple-file-error
- :pathname file
- :format-control "~S doesn't exist."
- :format-arguments (list file)))
+ (close file))
(multiple-value-bind (res err) (sb!unix:unix-unlink namestring)
(unless res
(simple-file-perror "couldn't delete ~A" namestring err))))
|