[Openmcl-devel] directory, create-directory, ...

Gary Byers gb at clozure.com
Mon Oct 6 05:57:56 PDT 2008



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/".
> 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.
>
> -Hans

And in the case of DIRECTORY, you're basically asking for a list of
all files whose pathnames that match DIRECTORY's first argument.  If
that argument is #P"/home/jsa/" (with the trailing slash), then

? (pathname-name #P"/home/jsa/")
NIL
? (pathname-type #P"/home/jsa/")
NIL

If you're able to create a file/directory with no name or type in that
directory, DIRECTORY should return it.  Since it's hard to create
such a file or directory, DIRECTORY correctly returns NIL (though
that may not have been what you expected and isn't analogous to
how the unix "ls" program behaves.)

It's often more useful to use wildcards as name and type components
in DIRECTORY's first argument:

? (directory #P"/home/jsa/*.lisp")

should return a list of all files with a type of "lisp" in that
directory, etc.


More information about the Openmcl-devel mailing list