Created
April 1, 2012 22:10
-
-
Save anonymous/2279100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn spit-to-zip | |
"Put the content in filename and zip it into zip-filename. Accept | |
one or more filename/content." | |
[zip-filename [filename content] & others] | |
(with-open [zip (java.util.zip.ZipOutputStream. | |
(clojure.java.io/output-stream zip-filename))] | |
(let [add-entry (fn [name cont & remain] | |
(-> zip (.putNextEntry (java.util.zip.ZipEntry. name))) | |
(.println (java.io.PrintWriter. zip true) cont) | |
(when (seq remain) | |
(recur (first remain) (second remain) (drop 2 remain))))] | |
(add-entry filename content others)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment