X3J13移除了一些对路径的操作函数,只保留pathname和directory相关的基本函数,cl-fad实现了路径操作的多数接口。
CL-USER> (ql:quickload "cl-fad")
To load "cl-fad":
Load 1 ASDF system:
cl-fad
; Loading "cl-fad"
("cl-fad")
CL-USER> (defun delete-empty-directory (filepath)
(cl-fad:walk-directory filepath (lambda (file)
(if (and
(cl-fad:directory-pathname-p file)
(null (cl-fad:list-directory file)))
(progn
(format t "delete ~a~%~%" file)
(cl-fad:delete-directory-and-files file))))
:directories t))
DELETE-EMPTY-DIRECTORY
CL-USER>
在“d:/迅雷下载”目录下新建aaaa空目录,然后执行一下语句:
CL-USER> (delete-empty-directory "d:/迅雷下载")
delete d:/迅雷下载/aaaaaa/