> Using an option for symlinks raises the possibility of using options to let
> delete-file handle everything, e.g.
>
> (delete-file "foo" :recursive true)
>
> instead of
>
> (delete-file-recursively "foo")
Yes. A potential argument for not conflating them might be that
"delete-file" is a pretty simple operation with hopefully clear
semantics, while a recursive directory tree operation immediately
opens up several questions. On the one hand, 'rm' sets a precedent
that it is okay. On the other hand, I think most API:s I've come
across do make a special distinction between plain unlinking and more
"elaborate" operations like tree walking removal.

Depending on how far one wants to go, the following may be overkill.
But my thoughts quickly stray towards providing a file tree walker
similar to Python's os.walk(), supporting top-down and bottom-up
traversal, following or not following symlinks and some customizable
error handling behavior. Implementing a 'delete-tree' would then be a
bottom-up walk with a delete action, along the lines of:

(defn delete-tree
  [top {:keys [follow-symlinks], :or [false]}]
  (doall (for [path (walk-tree top {:direction :bottom-up,
:follow-symlinks follow-symlinks})]
           (delete-file path))))

Of course none of this is incompatible with the interface of the
proposed delete-file-recursively (except possibly naming).

If you think it might be suitable for inclusion I'd be interested in
having a stab at it (it's a nicely bite-sized opportunity to write
some clojure).

-- 
/ Peter Schuller

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to