+(defun probe-directory (filename &key (error-if-does-not-exist 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
+ (let ((file-kind-fun
+ (or (find-symbol "NATIVE-FILE-KIND" :sb-impl)
+ (find-symbol "UNIX-FILE-KIND" :sb-unix))))
+ (when (eq :directory (funcall file-kind-fun (namestring path)))
+ path))
+ #-(or allegro clisp cmu lispworks sbcl scl)
+ (probe-file path)))
+ (if probe
+ probe
+ (when error-if-does-not-exist
+ (error "Directory ~A does not exist." filename)))))