Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add if-does-not-exist to delete-directory (thought that this was a ca…

…se but can't find it)

darcs-hash:20081204173839-3cc5d-d02e03f49f86385c93dbfe04a56058aee55efe27.gz
  • Loading branch information...
commit 1d0f2b92182ce5d8d13196cb104ba6a78af40493 1 parent 4172c88
@gwkkwg authored
Showing with 47 additions and 36 deletions.
  1. +47 −36 dev/utilities/files.lisp
View
83 dev/utilities/files.lisp
@@ -490,7 +490,8 @@ source."
(mapc #'close (list s1 s2)))
(values (null result) (reverse result))))
-(defun delete-directory (directory-spec &key (verbose? nil) (dry-run? nil))
+(defun delete-directory (directory-spec &key (verbose? nil) (dry-run? nil)
+ (if-does-not-exist :error))
(unless (directory-pathname-p directory-spec)
(setf directory-spec
(make-pathname
@@ -500,41 +501,51 @@ source."
:name (pathname-name directory-spec)
:type (pathname-type directory-spec)))))
:defaults directory-spec)))
- (flet ((directory-args ()
- #+allegro
- '(:directories t :files nil)
- #-allegro
- nil))
- (let* ((wild-directory
- (make-pathname
- :name :wild
- :type :wild
- :directory (append (pathname-directory directory-spec)
- (list :wild-inferiors))
- :defaults directory-spec))
- (directories (sort
- (apply #'directory wild-directory (directory-args))
- #'>
- :key (compose #'length #'namestring))))
- (mapc (lambda (directory)
- (when verbose?
- (format *debug-io* "~%;;; processing directory ~A" directory))
- (mapc (lambda (file)
- (when (probe-file file)
- (when verbose?
- (format *debug-io* "~%;; deleting ~A" file))
- (unless dry-run?
- (delete-file file))))
- (directory (make-pathname :name :wild
- :type :wild
- :defaults directory)))
- (when verbose?
- (format *debug-io* "~%;; deleting directory ~A" directory))
- (unless dry-run?
- (delete-file directory)))
- (append directories
- (list directory-spec)))
- (values nil))))
+ (cond ((probe-file directory-spec)
+ (flet ((directory-args ()
+ #+allegro
+ '(:directories t :files nil)
+ #-allegro
+ nil))
+ (let* ((wild-directory
+ (make-pathname
+ :name :wild
+ :type :wild
+ :directory (append (pathname-directory directory-spec)
+ (list :wild-inferiors))
+ :defaults directory-spec))
+ (directories (sort
+ (apply #'directory
+ wild-directory (directory-args))
+ #'>
+ :key (compose #'length #'namestring))))
+ (mapc (lambda (directory)
+ (when verbose?
+ (format *debug-io* "~%;;; processing directory ~A"
+ directory))
+ (mapc (lambda (file)
+ (when (probe-file file)
+ (when verbose?
+ (format *debug-io* "~%;; deleting ~A" file))
+ (unless dry-run?
+ (delete-file file))))
+ (directory (make-pathname :name :wild
+ :type :wild
+ :defaults directory)))
+ (when verbose?
+ (format *debug-io* "~%;; deleting directory ~A"
+ directory))
+ (unless dry-run?
+ (delete-file directory)))
+ (append directories
+ (list directory-spec)))
+ (values nil))))
+ (t
+ (ecase if-does-not-exist
+ (:ignore
+ )
+ (:error
+ (error "Directory ~a does not exist" directory-spec))))))
#+(or)
(defun directory-name-p (directory-spec)
Please sign in to comment.
Something went wrong with that request. Please try again.