X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=io.lisp;h=292af3c68382cc23da07f6603a1d89ee13a84c72;hp=7fbf186753e9f2ba731357bf66bdf60e0cd448c1;hb=c2974df32b94d3bd25c32fa2e181b1980da59631;hpb=d11d6cc43fd9227a8aeed28dc2cfecdbc587ec4a diff --git a/io.lisp b/io.lisp index 7fbf186..292af3c 100644 --- a/io.lisp +++ b/io.lisp @@ -9,7 +9,7 @@ ;;;; ;;;; $Id$ ;;;; -;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; This file, part of KMRCL, is Copyright (c) 2002-2003 by Kevin M. Rosenberg ;;;; ;;;; KMRCL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License @@ -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))))) + +