From d47be62eafdda89325110da3c39c51ca8b60be4c Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Fri, 2 Oct 2009 12:57:28 +0200 Subject: [PATCH] Add DELETE-FILES. --- src/os/os-unix.lisp | 19 +++++++++++++++++++ src/os/pkgdcl.lisp | 3 +-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/os/os-unix.lisp b/src/os/os-unix.lisp index 4bb2d1f..a14db26 100644 --- a/src/os/os-unix.lisp +++ b/src/os/os-unix.lisp @@ -494,6 +494,25 @@ the files and directories contained within. Returns T on success." (isys:eacces () (isys:syscall-error "Search permission is denied for ~S" directory))))) + +(defun delete-files (pathspec &key recursive) + (labels ((%delete-file (file) + (isys:%sys-unlink (file-path-namestring file))) + (%delete-directory (directory) + (isys:%sys-rmdir (file-path-namestring directory)))) + (let* ((pathspec (file-path pathspec)) + (kind (file-kind pathspec :follow-symlinks t))) + (case kind + (:directory + (if recursive + (walk-directory pathspec + (lambda (name kind) + (case kind + (:directory (%delete-directory name)) + (t (%delete-file name)))) + :directories :after) + (%delete-directory pathspec))) + (t (%delete-file pathspec)))))) ;;;; User information diff --git a/src/os/pkgdcl.lisp b/src/os/pkgdcl.lisp index 7577d6a..283dd6e 100644 --- a/src/os/pkgdcl.lisp +++ b/src/os/pkgdcl.lisp @@ -18,8 +18,7 @@ ;; Directories #:current-directory #:with-current-directory - ;; #:delete-directory - ;; #:delete-directory-and-files + #:delete-files #:directory-exists-p #:list-directory #:mapdir -- 2.11.4.GIT