[Openmcl-devel] #'directoryp

Gary Byers gb at clozure.com
Sun Sep 1 07:28:39 PDT 2002



On Sun, 1 Sep 2002, Sven Van Caekenberghe wrote:

> Hi,
>
> I found no simple way in ANSI common lisp to find out whether a file is
> a directory.
> In some old mcl documentation I found a function called directoryp.
> This function is part of openmcl, but is unimplemented (throws a break).
> Should it be implemented or removed ?

I vote for "implemented", if those are the only choices.

>
> I was using this implementation, but maybe it is too simple:
>
> (defun directory-p (filename)
>    (let ((pathname (pathname filename)))
>      (and (null (pathname-name pathname))
>              (null (pathname-type pathname)))))
>
> This seems to work for my purposes on openmcl.

The function CCL:DIRECTORY-PATHNAME-P does pretty much what your
definition does (it'll return true in a few more cases.)

If one only wants to return true in those cases where the pathname
actually denotes a real directory (and sometimes wants to be able
to distinguish links to directories from actual directories), one
might try:

(defun directoryp (path &optional (resolve-links t))
  (let* ((native-namestring (native-translated-namestring path)))
    (eq :directory (ccl::%unix-file-kind native-namestring (not resolve-links)))))

I think that that'd work pretty reliably, though whether that's the best
interface might require some thought.

(Well, not -that- much thought.  Certainly not another year's worth ...)

>
> ---
> Sven Van Caekenberghe - mailto:sven at beta9.be
> Beta Nine - software engineering - http://www.beta9.be
> ---
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
>
>


_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list