Gary King wrote:
OK, I /have/ misdiagnosed this. The logic seems actually busted in directory-pathname-p. The problem is that, at least on allegro, you can get a valid directory pathname whose name component is neither NIL, nor :unspecific, but "" (the empty string).
Ugh,
(member (pathname-name pathname) (list nil "" :unspecific) :test 'equal)
A source of the problem are pathnames that arise from things like this:
> (make-pathname :name "" :directory '(:absolute "tmp"))
#p"/tmp/" > (pathname-name *) ""
Added a call to namestring seems to be another way to canonical things so I think this will also work and feels (to me) a bit more portable:
(defun directory-pathname-p (pathname) (let ((pathname (namestring pathname))) (and (member (pathname-name pathname) (list nil :unspecific)) (member (pathname-type pathname) (list nil :unspecific)))))
wadayathink? Should I push?
Will this work correctly with logical pathnames?
The discussion on #lisp suggests a new wrinkle: are we trying to correct what are pathnames that incorrectly trying to name directories (this is what directory-pathname-p attempts unsuccessfully to do), or are we trying to correct pathnames that do not point to actual directories (e.g., ACL's PROBE-DIRECTORY)?
My earlier emails confuse these two together. If we are trying to do the former, we can't use the operating system, but if we are trying to do the latter, we pretty much /must/ use the operating system.
I'm inclined to the counsel of despair: the former isn't worth doing, and the latter seems likely to involve both too many cycles, and too much programmer effort to paper over cross-implementation and cross-OS inconsistencies.
Best, R