Skip to content

Instantly share code, notes, and snippets.

@jraines
Last active May 5, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jraines/c450b8fb3bd7a6b53e4b61f653babf50 to your computer and use it in GitHub Desktop.
Save jraines/c450b8fb3bd7a6b53e4b61f653babf50 to your computer and use it in GitHub Desktop.
defn- process-image-zipstream [zipstream]
(if-let [entry (.getNextEntry zipstream)]
(do
(println (str "Unzipping " (.getName entry)))
(with-open [o (io/output-stream (.getName entry))]
(loop [c (.read zipstream)] ;read next int from stream, mutates position of zipstream (so next .read() is different)
(if (not= c -1)
(do (.write o c)
(recur (.read zipstream))))))
(recur zipstream))))
(defn walkzip [file]
(with-open [z (ZipInputStream. (io/input-stream file))]
(process-image-zipstream z)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment