r10067: add keyword
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 1 Oct 2004 03:10:16 +0000 (03:10 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 1 Oct 2004 03:10:16 +0000 (03:10 +0000)
impl.lisp

index c17449c..a814cc4 100644 (file)
--- a/impl.lisp
+++ b/impl.lisp
          path))))
   
 
-(defun probe-directory (filename)
-  (let ((path (canonicalize-directory-name filename)))
-    #+allegro (excl:probe-directory path)
-    #+clisp (values
-            (ignore-errors
-              (#+lisp=cl ext:probe-directory #-lisp=cl lisp:probe-directory
-                         path)))
-    #+(or cmu scl) (when (eq :directory (unix:unix-file-kind (namestring path)))
-                    path)
-    #+lispworks (when (lw:file-directory-p path)
-                 path)
-    #+sbcl (when (eq :directory (sb-unix:unix-file-kind (namestring path)))
-            path)
-    #-(or allegro clisp cmu lispworks sbcl scl)
-    (probe-file path)))
-
+(defun probe-directory (filename &key (error-if-not-exists nil))
+  (let* ((path (canonicalize-directory-name filename))
+        (probe
+         #+allegro (excl:probe-directory path)
+         #+clisp (values
+                  (ignore-errors
+                    (#+lisp=cl ext:probe-directory
+                               #-lisp=cl lisp:probe-directory
+                               path)))
+         #+(or cmu scl) (when (eq :directory
+                                  (unix:unix-file-kind (namestring path)))
+                          path)
+         #+lispworks (when (lw:file-directory-p path)
+                       path)
+         #+sbcl (when (eq :directory
+                          (sb-unix:unix-file-kind (namestring path)))
+                  path)
+         #-(or allegro clisp cmu lispworks sbcl scl)
+         (probe-file path)))
+    (if probe
+       probe
+       (when error-if-not-exists
+         (error "Directory ~A does not exist." filename)))))
 
 (defun cwd (&optional dir)
   "Change directory and set default pathname"