X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ffilesys.lisp;h=cd62fa6a4065ca95d1710cadd7554da0c39ee902;hb=bd2df60f7c3f579a9c7610925c79a0e783adaa0e;hp=482b34b4fc316cf117e49738d17a41a23f3f24c8;hpb=1dc69aa156beb876b51c1ad23db73730723bce6d;p=sbcl.git diff --git a/src/code/filesys.lisp b/src/code/filesys.lisp index 482b34b..cd62fa6 100644 --- a/src/code/filesys.lisp +++ b/src/code/filesys.lisp @@ -471,17 +471,18 @@ or if PATHSPEC is a wild pathname." (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* ((pathname (translate-logical-pathname file)) + (namestring (native-namestring pathname :as-file t))) + (truename file) ; for error-checking side-effect + #!+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))))