From 13484934fdf47d25d4243b36abd4b2b81e1a7bdd Mon Sep 17 00:00:00 2001 From: Sohalt Date: Thu, 7 Mar 2024 17:20:23 +0100 Subject: [PATCH] Allow unzip to take an InputStream to unzip (#125) --- src/babashka/fs.cljc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/babashka/fs.cljc b/src/babashka/fs.cljc index c618b80..edc21fb 100644 --- a/src/babashka/fs.cljc +++ b/src/babashka/fs.cljc @@ -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]) @@ -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)]