Gary King writes:
(defun pathname-name+type (pathname) "Returns a new pathname consisting of only the name and type from a non-wild pathname." (make-pathname :name (pathname-name pathname) :type (pathname-type pathname)))
I believe that FILE-NAMESTRING is supposed to do roughly what you want here.
(defun ensure-directory-pathname (pathname) (if (directory-pathname-p pathname) pathname (make-pathname :directory `(,@(pathname-directory pathname) ,(namestring (pathname-name+type pathname))))))
This loses the device component from PATHNAME, and is otherwise prone to fail in case the host component of *DEFAULT-PATHNAME-DEFAULTS* differs from the host component of PATHNAME. How about
(make-pathname :defaults pathname :directory (append (pathname-directory pathname) (list (file-namestring pathname))) :name nil :type nil :version nil)
?
Regards, Richard