Jon S. Anthony | 6 Oct 14:48
Favicon

directory, create-directory, ...

I have tried these on both Mac and Linux and they behave the same, and
that is to do nothing.  They don't error, but just return.
create-directory returns the multiple values: path of the supposedly new
directory and nil:

(create-directory "/home/jsa/TEST") => #p"/home/jsa/TEST", NIL

But the directory isn't created.  I also haven't found what the MODE
keyword is supposed to be or do.

directory returns nil whether or not the directory given exists:

(directory "/home/jsa") => nil
(directory "/gobbledegook") => nil

I also couldn't find the meaning of the various keywords to this either,
but tried various permutations of :files t, :directories t, etc. with no
apparent effect.

I tried both with path syntax input as well: #p"/home/jsa/TEST",
#p"/home/jsa", etc.  Nothing.

Anyone have any ideas??

/Jon

Re: directory, create-directory, ...

On Mon, Oct 6, 2008 at 14:51, Jon S. Anthony <j-anthony <at> comcast.net> wrote:
> I have tried these on both Mac and Linux and they behave the same, and
> that is to do nothing.  They don't error, but just return.
> create-directory returns the multiple values: path of the supposedly new
> directory and nil:
>
> (create-directory "/home/jsa/TEST") => #p"/home/jsa/TEST", NIL
>
> But the directory isn't created.  I also haven't found what the MODE
> keyword is supposed to be or do.
>
>
> directory returns nil whether or not the directory given exists:
>
> (directory "/home/jsa") => nil
> (directory "/gobbledegook") => nil
>
> I also couldn't find the meaning of the various keywords to this either,
> but tried various permutations of :files t, :directories t, etc. with no
> apparent effect.
>
> I tried both with path syntax input as well: #p"/home/jsa/TEST",
> #p"/home/jsa", etc.  Nothing.
>
> Anyone have any ideas??

Your directory pathnames need to end in a slash, as in #P"/home/jsa/".
 DIrectories and files are treated differently in the CL pathname
system.  See http://gigamonkeys.com/book/files-and-file-io.html#filenames
for a discussion on the history and usage of pathnames.
(Continue reading)

Gary Byers | 6 Oct 14:57

Re: directory, create-directory, ...


On Mon, 6 Oct 2008, Hans Hübner wrote:

> On Mon, Oct 6, 2008 at 14:51, Jon S. Anthony <j-anthony <at> comcast.net> wrote:
>> I have tried these on both Mac and Linux and they behave the same, and
>> that is to do nothing.  They don't error, but just return.
>> create-directory returns the multiple values: path of the supposedly new
>> directory and nil:
>>
>> (create-directory "/home/jsa/TEST") => #p"/home/jsa/TEST", NIL
>>
>> But the directory isn't created.  I also haven't found what the MODE
>> keyword is supposed to be or do.
>>
>>
>> directory returns nil whether or not the directory given exists:
>>
>> (directory "/home/jsa") => nil
>> (directory "/gobbledegook") => nil
>>
>> I also couldn't find the meaning of the various keywords to this either,
>> but tried various permutations of :files t, :directories t, etc. with no
>> apparent effect.
>>
>> I tried both with path syntax input as well: #p"/home/jsa/TEST",
>> #p"/home/jsa", etc.  Nothing.
>>
>> Anyone have any ideas??
>
> Your directory pathnames need to end in a slash, as in #P"/home/jsa/".
(Continue reading)

Favicon

Re: directory, create-directory, ...


I sent this out, but I think I forgot to include the group...

Anyway, yes, (directory "/x/y/*.lisp") for example does what you would
expect.  Using only a wild card though doesn't get all files: (directory
"/x/y/*") => nil.  You can use (directory "/x/y/*.*") but that would seem
to indicate only files with a "." in their name.  It may be that this is
where the various keywords to directory come into play.  Are/where are
these described?  Also, R.Stoye informed me that the MODE keyword for
create-directory is for indicating the unix mode/permissions for the
directory.  Again, where is this impl specific type stuff described for
CCL?  For example, I now know what MODE is for, but still don't know how it
is specified (ala' chmod or ???)

Thanks!

/Jon

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://link.mail2web.com/mail2web
Chun Tian (binghe | 6 Oct 20:15

Re: directory, create-directory, ...

Try this one:

(directory (make-pathname :name :wild :type :wild :defaults #p"/x/ 
y/") :directories t)

or just

(directory #p"/x/y/*.*" :directories t)

I think you'd better use CL-FAD package instead. I just learn above by  
reading CL-FAD's LIST-DIRECTORY function:

(defun list-directory (dirname)
   "Returns a fresh list of pathnames corresponding to the truenames of
all files within the directory named by the non-wild pathname
designator DIRNAME.  The pathnames of sub-directories are returned in
directory form - see PATHNAME-AS-DIRECTORY."
   (when (wild-pathname-p dirname)
     (error "Can only list concrete directory names."))
   #+:ecl
   (let ((dir (pathname-as-directory dirname)))
     (concatenate 'list
                  (directory (merge-pathnames (pathname "*/") dir))
                  (directory (merge-pathnames (pathname "*.*") dir))))
   #-:ecl
   (let ((wildcard (directory-wildcard dirname)))
     #+:abcl (system::list-directory dirname)
     #+(or :sbcl :cmu :scl :lispworks) (directory wildcard)
     #+(or :openmcl :digitool) (directory wildcard :directories t)
     #+:allegro (directory wildcard :directories-are-files nil)
(Continue reading)

Gary Byers | 6 Oct 22:01

Re: directory, create-directory, ...

I started to write a much longer response, but it was amounting to a
CL pathname tutorial.  As Hans pointed out, Peter Seibel has already
written one (and it appears to be quite good).  If reality doesn't
match one's intuitions about it, there are two general explanations
for that:

  1) Reality is wrong somehow.
  2) One's intuitions are ill-founded.

I strongly suspect that reality is often just plain wrong, but that
suspicion has never done me much good ...  Please read Peter's tutorial.

The keyword arguments to DIRECTORY should really be documented
somewhere other than in comments in the source, but they have nothing
to do with how namestrings are parsed into pathnames in general or in
a particular implementation.  (They do have to do with whether things
which could potentially be included in DIRECTORY's results are in fact
included in those results.)

Likewise, it'd be better if the MODE argument to CREATE-DIRECTORY
was documented (via DOCUMENTATION or the manual or both.)   It'd
be even worse than it is if sources weren't available or if M-.
didn't work.

On Mon, 6 Oct 2008, j-anthony <at> comcast.net wrote:

>
> I sent this out, but I think I forgot to include the group...
>
> Anyway, yes, (directory "/x/y/*.lisp") for example does what you would
(Continue reading)

Raffael Cavallaro | 6 Oct 23:29

Re: directory, create-directory, ...


On Oct 6, 2008, at 4:01 PM, Gary Byers wrote:

> It'd
> be even worse than it is if sources weren't available or if M-.
> didn't work.

As a long time user of mcl/openmcl/clozure cl I'll just chime in to  
say that M-. is truly your friend.

Raffael Cavallaro, Ph.D.
raffaelcavallaro <at> mac.com
Jon S. Anthony | 7 Oct 06:45
Favicon

Re: directory, create-directory, ...


> I strongly suspect that reality is often just plain wrong, but that
> suspicion has never done me much good ...  Please read Peter's tutorial.

I have, but really, this just isn't the issue.

> The keyword arguments to DIRECTORY should really be documented
> somewhere other than in comments in the source,

This is the issue.  Though I do sympathize with the usual issues around
open source.  I am definitely spoiled by the completeness and direct
access available on this sort of impl specific stuff in Allegro (and no
doubt in other commercial offerings).

>  but they have nothing
> to do with how namestrings are parsed into pathnames in general or in
> a particular implementation.  (They do have to do with whether things
> which could potentially be included in DIRECTORY's results are in fact
> included in those results.)

Well, yes, _exactly_.

> Likewise, it'd be better if the MODE argument to CREATE-DIRECTORY
> was documented (via DOCUMENTATION or the manual or both.)

Again, exactly.  But also again, I understand the constraints in an open
source world.  For example, I am using CCL (and mostly without much
issues) in a startup, and frankly the 12-15 hours a day at that work
don't leave me in much of a mood or position to root around and find
this information and then document it for the good of the "community".
(Continue reading)


Gmane