(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))))
;; end of the line
(funcall function subdirectory))
((or (eq :wild next) (typep next 'pattern))
- (lambda (pathname)
- (map-wild function more pathname)))
+ (map-wild function more subdirectory))
((eq :wild-inferiors next)
- (lambda (pathname)
- (map-wild-inferiors function more pathname)))
+ (map-wild-inferiors function more subdirectory))
(t
- (lambda (pathname)
- (let ((this (pathname-directory pathname)))
- (when (equal next (car (last this)))
- (map-matching-directories
- function
- (make-pathname :directory (append this more)
- :defaults pathname)))))))))
+ (let ((this (pathname-directory subdirectory)))
+ (map-matching-directories
+ function
+ (make-pathname :directory (append this more)
+ :defaults subdirectory)))))))
(map-directory
(if (eq :wild this)
#'cont