summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-08-07 18:44:24 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-08-07 18:42:30 +0000
commit16e0e17c53f24e694314bec7a658f650d206da58 (patch)
treee487960d0e7cbf8e2057a4decd4f64235923ce81
parent8e43bfd153208469676e9c6cd0852df23142cfee (diff)
parentc48199457bc0ed96404414ba4d4ad15e4f0fd6bb (diff)
downloadlibcore-16e0e17c53f24e694314bec7a658f650d206da58.zip
libcore-16e0e17c53f24e694314bec7a658f650d206da58.tar.gz
libcore-16e0e17c53f24e694314bec7a658f650d206da58.tar.bz2
Merge "Revert "Remove nameLength field from ZipEntry.""
-rw-r--r--luni/src/main/java/java/util/zip/ZipEntry.java7
-rw-r--r--luni/src/main/native/java_util_jar_StrictJarFile.cpp8
2 files changed, 10 insertions, 5 deletions
diff --git a/luni/src/main/java/java/util/zip/ZipEntry.java b/luni/src/main/java/java/util/zip/ZipEntry.java
index d007b0f..217cc3c 100644
--- a/luni/src/main/java/java/util/zip/ZipEntry.java
+++ b/luni/src/main/java/java/util/zip/ZipEntry.java
@@ -52,6 +52,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
byte[] extra;
+ int nameLength = -1;
long localHeaderRelOffset = -1;
long dataOffset = -1;
@@ -68,7 +69,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
ZipEntry(String name, String comment, long crc, long compressedSize,
long size, int compressionMethod, int time, int modDate, byte[] extra,
- long localHeaderRelOffset, long dataOffset) {
+ int nameLength, long localHeaderRelOffset, long dataOffset) {
this.name = name;
this.comment = comment;
this.crc = crc;
@@ -78,6 +79,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
this.time = time;
this.modDate = modDate;
this.extra = extra;
+ this.nameLength = nameLength;
this.localHeaderRelOffset = localHeaderRelOffset;
this.dataOffset = dataOffset;
}
@@ -338,6 +340,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
compressionMethod = ze.compressionMethod;
modDate = ze.modDate;
extra = ze.extra;
+ nameLength = ze.nameLength;
localHeaderRelOffset = ze.localHeaderRelOffset;
dataOffset = ze.dataOffset;
}
@@ -409,7 +412,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
compressedSize = ((long) it.readInt()) & 0xffffffffL;
size = ((long) it.readInt()) & 0xffffffffL;
- int nameLength = it.readShort() & 0xffff;
+ nameLength = it.readShort() & 0xffff;
int extraLength = it.readShort() & 0xffff;
int commentByteCount = it.readShort() & 0xffff;
diff --git a/luni/src/main/native/java_util_jar_StrictJarFile.cpp b/luni/src/main/native/java_util_jar_StrictJarFile.cpp
index 715082b..7611749 100644
--- a/luni/src/main/native/java_util_jar_StrictJarFile.cpp
+++ b/luni/src/main/native/java_util_jar_StrictJarFile.cpp
@@ -32,7 +32,8 @@ static void throwIoException(JNIEnv* env, const int32_t errorCode) {
jniThrowException(env, "java/io/IOException", ErrorCodeString(errorCode));
}
-static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName) {
+static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName,
+ const uint16_t nameLength) {
ScopedLocalRef<jclass> zipEntryClass(env, env->FindClass("java/util/zip/ZipEntry"));
const jmethodID zipEntryCtor = env->GetMethodID(zipEntryClass.get(), "<init>",
"(Ljava/lang/String;Ljava/lang/String;JJJIII[BIJJ)V");
@@ -48,6 +49,7 @@ static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName
static_cast<jint>(0), // time
static_cast<jint>(0), // modData
NULL, // byte[] extra
+ static_cast<jint>(nameLength),
static_cast<jlong>(-1), // local header offset
static_cast<jlong>(entry.offset));
}
@@ -133,7 +135,7 @@ static jobject StrictJarFile_nativeNextEntry(JNIEnv* env, jobject, jlong iterati
entryNameCString[entryName.name_length] = '\0';
ScopedLocalRef<jstring> entryNameString(env, env->NewStringUTF(entryNameCString.get()));
- return newZipEntry(env, data, entryNameString.get());
+ return newZipEntry(env, data, entryNameString.get(), entryName.name_length);
}
static jobject StrictJarFile_nativeFindEntry(JNIEnv* env, jobject, jlong nativeHandle,
@@ -150,7 +152,7 @@ static jobject StrictJarFile_nativeFindEntry(JNIEnv* env, jobject, jlong nativeH
return NULL;
}
- return newZipEntry(env, data, entryName);
+ return newZipEntry(env, data, entryName, entryNameChars.size());
}
static void StrictJarFile_nativeClose(JNIEnv*, jobject, jlong nativeHandle) {