Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn- jar-stream-seq [stream]
- (take-while #(not= nil %) (repeatedly #(.getNextEntry stream))))
- (defn- create-parent [archive-entry]
- (-> archive-entry (.getParentFile) (.mkdirs)))
- (defn- extract-entry [entry dir jar-stream]
- (let [archive-entry (file dir (.getName entry))]
- (create-parent archive-entry)
- (cond (.isDirectory entry) (.mkdir archive-entry)
- :else (with-open [fos (FileOutputStream. archive-entry)]
- (copy jar-stream fos)))))
- (defn unjar [src dest]
- (with-open [jar-stream (JarArchiveInputStream. (file-in-stream (file-str src)))]
- (let [dir (file dest)]
- (doseq [entry (jar-stream-seq jar-stream)] (extract-entry entry dir jar-stream)))))
Add Comment
Please, Sign In to add comment