[Openmcl-devel] upcoming 1.6 release

R. Matthew Emerson rme at clozure.com
Tue Oct 12 10:25:35 PDT 2010


On Oct 11, 2010, at 5:55 PM, Zach Beane wrote:

> Michael Minerva <minerva at agentsheets.com> writes:
> 
>> I've had success using recursive-delete-directory from pathnames.lisp to delete directories.  
> 
> I noticed both CCL::RECURSIVE-DELETE-DIRECTORY and CCL::%RMDIR, but
> hesitated to use them because they're not exported. Are they the best
> supported option, or is there something else I should use?
> 
> cl-fad references ccl:delete-directory, but I don't see that anywhere.

CL-FAD itself puts a delete-directory function into the CCL package.  It really shouldn't be putting stuff in the CCL package.

I think what we should do is add ccl:delete-directory to CCL.

It seems pointless to have a function that deletes a directory, but only if it's empty:  usually what one wants is to remove a directory and all its contents.  There seems little use in having something like (delete-directory :recursive-p nil), but maybe there's a reason I haven't thought of.

Anyway, I added and exported delete-directory to the trunk, and it'll be in 1.6.  It deletes a directory and all its contents.

For supporting earlier releases, I don't suppose there's anything better to use than ccl::%rmdir.  You could wrap it up in a little function like this:

(defun my-delete-directory (path)
  "Delete the empty directory specified by PATH."
  (let* ((namestring (ccl:native-translated-namestring path))
	 (err (ccl::%rmdir namestring)))
    (or (eql 0 err) (ccl::signal-file-error err path))))

recursive-delete-directory calls cl:directory without using :follow-links nil.  This makes it end up deleting the target of a symbolic link rather than the link itself.  This might lead to, er, dissatisfaction, so I'm inclined to avoid recommending it.





More information about the Openmcl-devel mailing list