Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. (defmacro with-entry
  2. "zip-output-stream に、エントリーを追加する"
  3. [[entry-name zip-output-stream] & body]
  4. `(try
  5. (.putNextEntry ^ZipOutputStream ~zip-output-stream
  6. (ZipEntry. ^String ~entry-name))
  7. ~@body
  8. (finally (.closeEntry ~zip-output-stream))))
  9.  
  10. (defn make-archive [output-filename contents]
  11. (with-open [output (ZipOutputStream. (io/output-stream output-filename))]
  12. (doseq [{:keys [from to]} contents]
  13. (with-entry [to output]
  14. (with-open [in (io/input-stream from)]
  15. (io/copy in output))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement