Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZIP64 support (commons-compress) #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<param name="android-package" value="org.apache.cordova.Zip"/>
</feature>
</config-file>

<framework src="src/android/compress.gradle" custom="true" type="gradleReference" />
</platform>

<platform name="ios">
Expand Down
15 changes: 8 additions & 7 deletions src/android/Zip.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -141,7 +143,6 @@ private void unzipSync(CordovaArgs args, CallbackContext callbackContext) {
}
progress.addLoaded(ze.getCompressedSize());
updateProgress(callbackContext, progress);
zis.closeEntry();
}

// final progress = 100%
Expand Down
3 changes: 3 additions & 0 deletions src/android/compress.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
compile 'org.apache.commons:commons-compress:1.8'
}