summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2015-01-26 10:13:25 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-01-26 10:13:25 +0000
commitf6bc28f002e7a43d92b1955c82fd8a030cfcb182 (patch)
treeb4d2997ca707ae497a58ddc8f936014877916aa0
parent2e5cf008b02050101a4eb8ae987bf570633faaa3 (diff)
parent38246b3b0087f673d9257f0f6041e99400edf73f (diff)
downloadandroid_dalvik-f6bc28f002e7a43d92b1955c82fd8a030cfcb182.tar.gz
android_dalvik-f6bc28f002e7a43d92b1955c82fd8a030cfcb182.tar.bz2
android_dalvik-f6bc28f002e7a43d92b1955c82fd8a030cfcb182.zip
am 38246b3b: Merge "Don\'t discard directory entries in jar files."
* commit '38246b3b0087f673d9257f0f6041e99400edf73f': Don't discard directory entries in jar files.
-rw-r--r--dx/src/com/android/dx/cf/direct/ClassPathOpener.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/dx/src/com/android/dx/cf/direct/ClassPathOpener.java b/dx/src/com/android/dx/cf/direct/ClassPathOpener.java
index c9fe275cd..26fbca029 100644
--- a/dx/src/com/android/dx/cf/direct/ClassPathOpener.java
+++ b/dx/src/com/android/dx/cf/direct/ClassPathOpener.java
@@ -242,9 +242,6 @@ public class ClassPathOpener {
*/
private boolean processArchive(File file) throws IOException {
ZipFile zip = new ZipFile(file);
- ByteArrayOutputStream baos = new ByteArrayOutputStream(40000);
- byte[] buf = new byte[20000];
- boolean any = false;
ArrayList<? extends java.util.zip.ZipEntry> entriesList
= Collections.list(zip.entries());
@@ -259,28 +256,31 @@ public class ClassPathOpener {
consumer.onProcessArchiveStart(file);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(40000);
+ byte[] buf = new byte[20000];
+ boolean any = false;
+
for (ZipEntry one : entriesList) {
- if (one.isDirectory()) {
- continue;
- }
+ final boolean isDirectory = one.isDirectory();
String path = one.getName();
if (filter.accept(path)) {
- InputStream in = zip.getInputStream(one);
-
- baos.reset();
- for (;;) {
- int amt = in.read(buf);
- if (amt < 0) {
- break;
+ final byte[] bytes;
+ if (!isDirectory) {
+ InputStream in = zip.getInputStream(one);
+
+ baos.reset();
+ int read;
+ while ((read = in.read(buf)) != -1) {
+ baos.write(buf, 0, read);
}
- baos.write(buf, 0, amt);
+ in.close();
+ bytes = baos.toByteArray();
+ } else {
+ bytes = new byte[0];
}
- in.close();
-
- byte[] bytes = baos.toByteArray();
any |= consumer.processFileBytes(path, one.getTime(), bytes);
}
}