r7814: add implementation-dependent file, new impl-dependent commands
[kmrcl.git] / io.lisp
diff --git a/io.lisp b/io.lisp
index 7fbf186753e9f2ba731357bf66bdf60e0cd448c1..4dea295f5e789d6dacb1c2eb86fe99c155d71487 100644 (file)
--- a/io.lisp
+++ b/io.lisp
   (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)))))
+
+