From: Tim Bradshaw
Subject: non-destructive counterpart of ENSURE-DIRECTORIES-EXIST?
Date: 
Message-ID: <ey3y9pwabij.fsf@cley.com>
Is there any way (in standard CL) of asking if directories exist
*without possibly creating them*? it seems to me that there isn't, but
I may be missing something.  On Unixoid systems you can often
empirically use PROBE-FILE to do this -- (probe-file (make-pathname
:directory '(:absolute "usr" "local"))) say -- but I'm pretty sure
that works just by coincidences in how the Unix filesystem works and
how the Lisp system talks to it (for instance, in Genera it doesn't
work on the native filesystem, and it doesn't work for #p"fs:/" but
*does* for #p"fs:/.", where FS is a Unix host, which I think is OK).

--tim

From: Kent M Pitman
Subject: Re: non-destructive counterpart of ENSURE-DIRECTORIES-EXIST?
Date: 
Message-ID: <sfwvgl0h7h6.fsf@world.std.com>
Tim Bradshaw <···@cley.com> writes:

> Is there any way (in standard CL) of asking if directories exist
> *without possibly creating them*? it seems to me that there isn't, but
> I may be missing something.  On Unixoid systems you can often
> empirically use PROBE-FILE to do this -- (probe-file (make-pathname
> :directory '(:absolute "usr" "local"))) say -- but I'm pretty sure
> that works just by coincidences in how the Unix filesystem works and
> how the Lisp system talks to it (for instance, in Genera it doesn't
> work on the native filesystem, and it doesn't work for #p"fs:/" but
> *does* for #p"fs:/.", where FS is a Unix host, which I think is OK).


If there were a distinguished no-such-directory error, you might have half
a hope of winning.  I don't know of any way to do this portably.

The issue is somewhat complicated, btw, because in networked and other
mutable file systems, a directory can fail to exist as a transient
error and not a permanent one.  e.g., a host might be down, a disk
might not be mounted, or a share might not be defined even though its
disk contents are available under another name.  This complexity is
one reason the problem was not addressed for the standard.  The Lisp
Machine had a VERY elaborate set of conditions for dealing with this,
but they were necessarily based on multiple-inheritance, and there had
not yet been sufficient buy-in of multiple-inheritance that people were
willing to embroil the condition system. The entire condition system
was painstakingly devised to allow single-inheritance as a hedge against
implementations backing off of (or not moving immediately) clos.  But it
was not possible to do a correct error system design of missing directory
based on this.

A functional operator that just checked for directory-available-for-write
probably could have been devised, but wasn't.
From: Tim Bradshaw
Subject: Re: non-destructive counterpart of ENSURE-DIRECTORIES-EXIST?
Date: 
Message-ID: <ey3k81ga2sz.fsf@cley.com>
* Kent M Pitman wrote:

> A functional operator that just checked for directory-available-for-write
> probably could have been devised, but wasn't.

yes this is pretty much what I'm after.  Obviously things can change
out from under you - but there is already this problem with
ENSURE-DIRECTORIES-EXIST.

--tim
From: Raymond Wiker
Subject: Re: non-destructive counterpart of ENSURE-DIRECTORIES-EXIST?
Date: 
Message-ID: <86g0c4tx0n.fsf@raw.grenland.fast.no>
Tim Bradshaw <···@cley.com> writes:

> Is there any way (in standard CL) of asking if directories exist
> *without possibly creating them*? it seems to me that there isn't, but
> I may be missing something.  On Unixoid systems you can often
> empirically use PROBE-FILE to do this -- (probe-file (make-pathname
> :directory '(:absolute "usr" "local"))) say -- but I'm pretty sure
> that works just by coincidences in how the Unix filesystem works and
> how the Lisp system talks to it (for instance, in Genera it doesn't
> work on the native filesystem, and it doesn't work for #p"fs:/" but
> *does* for #p"fs:/.", where FS is a Unix host, which I think is OK).

        Just a guess: use #'directory, possibly inside a catch clause?
According to the HyperSpec, an error of type file-error is signalled
if the directory operation was unsuccessful. Further, it seems that
some implementations (e.g, SBCL, and likely also CMUCL) return nil if
the directory does not exist.

-- 
Raymond Wiker
·············@fast.no