From 410d5e882aa0cc4769ff7406b9d178825d173dea Mon Sep 17 00:00:00 2001 From: Chris Dell Date: Sat, 25 Nov 2017 18:57:06 +0000 Subject: [PATCH] ZIP64 support (commons-compress) --- plugin.xml | 2 ++ src/android/Zip.java | 15 ++++++++------- src/android/compress.gradle | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 src/android/compress.gradle diff --git a/plugin.xml b/plugin.xml index 746ea4fe..4b2be89b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -23,6 +23,8 @@ + + diff --git a/src/android/Zip.java b/src/android/Zip.java index 4b5de862..f5a71a54 100644 --- a/src/android/Zip.java +++ b/src/android/Zip.java @@ -6,11 +6,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.FileNotFoundException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - import android.net.Uri; + +import org.apache.commons.compress.archivers.ArchiveInputStream; +import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; + import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaResourceApi.OpenForReadResult; @@ -109,14 +111,14 @@ private void unzipSync(CordovaArgs args, CallbackContext callbackContext) { } // The inputstream is now pointing at the start of the actual zip file content. - ZipInputStream zis = new ZipInputStream(inputStream); + ArchiveInputStream zis = new ArchiveStreamFactory().createArchiveInputStream("zip", inputStream); inputStream = zis; - ZipEntry ze; + ZipArchiveEntry ze; byte[] buffer = new byte[32 * 1024]; boolean anyEntries = false; - while ((ze = zis.getNextEntry()) != null) + while ((ze = (ZipArchiveEntry) zis.getNextEntry()) != null) { anyEntries = true; String compressedName = ze.getName(); @@ -141,7 +143,6 @@ private void unzipSync(CordovaArgs args, CallbackContext callbackContext) { } progress.addLoaded(ze.getCompressedSize()); updateProgress(callbackContext, progress); - zis.closeEntry(); } // final progress = 100% diff --git a/src/android/compress.gradle b/src/android/compress.gradle new file mode 100644 index 00000000..138fc2fd --- /dev/null +++ b/src/android/compress.gradle @@ -0,0 +1,3 @@ +dependencies { + compile 'org.apache.commons:commons-compress:1.8' +}