Skip to content

Commit

Permalink
Allow unzip to take an InputStream to unzip (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohalt authored Mar 7, 2024
1 parent e22269c commit 1348493
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/babashka/fs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require [clojure.java.io :as io]
[clojure.string :as str]
[clojure.walk :as walk])
(:import [java.io File]
(:import [java.io File InputStream]
[java.net URI]
[java.nio.file StandardOpenOption CopyOption
#?@(:bb [] :clj [DirectoryStream]) #?@(:bb [] :clj [DirectoryStream$Filter])
Expand Down Expand Up @@ -966,11 +966,11 @@
([zip-file dest] (unzip zip-file dest nil))
([zip-file dest {:keys [replace-existing]}]
(let [output-path (as-path dest)
zip-file (as-path zip-file)
_ (create-dirs dest)
cp-opts (->copy-opts replace-existing nil nil nil)]
(with-open
[fis (Files/newInputStream zip-file (into-array java.nio.file.OpenOption []))
[fis (if (instance? InputStream zip-file) zip-file
(Files/newInputStream (as-path zip-file) (into-array java.nio.file.OpenOption [])))
zis (ZipInputStream. fis)]
(loop []
(let [entry (.getNextEntry zis)]
Expand Down

0 comments on commit 1348493

Please sign in to comment.