Skip to content

Instantly share code, notes, and snippets.

@olslash
Last active December 27, 2016 05:51
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 olslash/4804c246b02e5a9e7237aed3ec41ed07 to your computer and use it in GitHub Desktop.
Save olslash/4804c246b02e5a9e7237aed3ec41ed07 to your computer and use it in GitHub Desktop.
(defn gunzip
"Writes the contents of input to output, decompressed.
input: something which can be opened by io/input-stream.
The bytes supplied by the resulting stream must be gzip compressed.
output: something which can be copied to by io/copy."
[input output & opts]
(with-open [input (-> input io/input-stream GZIPInputStream.)]
(apply io/copy input output opts)))
;; ... snip ...
(defn -main []
(let [sources (map #(vector (clojure.string/replace (.getName %) #".xml$" "")
(get-first-source-url %))
sources)] ;; a list of vectors: [filename url]
(doall (pmap #(-> (second %)
io/input-stream
(gunzip (io/file (format "./docsets/%s.docset" (first %)))))
(take 1 sources))))) ;; just try one for testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment