G'day all,

Thanks Miki for fs, also coming from a Python background I am enjoying
the familiarity!

The thing that I most often use tempdir for is unit testing where I
want to clean up immediately in a finally block.

(defmacro with-tempdir
  "bindings => [name path]

   Evaluates body in a try expression with the name bound to the path
   supplied. A finally clause calls (fs/deltree on name).

   E.g.

   (with-open [d (fs/tempdir)]
     (println d))

  "
  [bindings & body]
  (assert
   (and
    (vector? bindings)
    (= 2 (count bindings))
    (symbol? (bindings 0))))
  `(let ~bindings
     (try
       ~@body
       (finally (deltree ~(bindings 0))))))

Wondering whether this already exists or could be candidate for
inclusion in fs. It can use a bit of cleaning up and its not the kind
of thing that I like to maintain in my codebase.


Cheers,
David

-- 
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