X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=io.lisp;h=4dea295f5e789d6dacb1c2eb86fe99c155d71487;hp=7fbf186753e9f2ba731357bf66bdf60e0cd448c1;hb=6f333885c716800cf85c2986a3b835efe0e54e70;hpb=d11d6cc43fd9227a8aeed28dc2cfecdbc587ec4a diff --git a/io.lisp b/io.lisp index 7fbf186..4dea295 100644 --- a/io.lisp +++ b/io.lisp @@ -190,3 +190,25 @@ (when (probe-file #p"/dev/null") (open-device-stream #p"/dev/null" :output)) ) + + +(defun directory-tree (filename) + "Returns a tree of pathnames for sub-directories of a directory" + (let* ((root (canonicalize-directory-name filename)) + (subdirs (loop for path in (directory + (make-pathname :name :wild + :type :wild + :defaults root)) + when (probe-directory path) + collect (canonicalize-directory-name path)))) + (when (find nil subdirs) + (error "~A" subdirs)) + (when (null root) + (error "~A" root)) + (if subdirs + (cons root (mapcar #'directory-tree subdirs)) + (if (probe-directory root) + (list root) + (error "root not directory ~A" root))))) + +