From: Mark Wooding Date: Sun, 22 May 2011 14:07:33 +0000 (+0100) Subject: frontend.lisp: Hack around CLisp's bizarreness. X-Git-Url: https://git.distorted.org.uk/~mdw/zone/commitdiff_plain/afb5d9e651733a0e7aacf42f892422931041f637 frontend.lisp: Hack around CLisp's bizarreness. Annoyingly, CLisp's PROBE-FILE signals an error if you give it a directory name. Bodge around this. I pinched the basic idea from the CL-FAD package, by Peter Seibel and Edi Weitz. --- diff --git a/frontend.lisp b/frontend.lisp index 1ff3e2f..7801a8a 100644 --- a/frontend.lisp +++ b/frontend.lisp @@ -33,9 +33,28 @@ (defvar opt-format :bind "Which format to use on output.") +(defun directory-exists-p (name) + + ;; Make a pathname for NAME which has the right form for a directory. + (let ((dirpath + (let ((path (pathname name))) + (if (null (pathname-name path)) + path + (make-pathname :directory + (append (or (pathname-directory path) + (list :relative)) + (list (pathname-name path))) + :name nil + :type nil + :defaults path))))) + + ;; Now check that it exists. + #+clisp (and (ext:probe-directory dirpath) (truename dirpath)) + #-clisp (probe-file dirpath))) + (eval-when (:compile-toplevel :load-toplevel) (defopthandler dir (var arg) () - (let ((path (probe-file arg))) + (let ((path (directory-exists-p arg))) (if (and path (not (pathname-name path))) (setf var path)