< prev index next >

src/java.base/share/native/libzip/ZipFile.c

Print this page

        

*** 82,96 **** } JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name, jint mode, jlong lastModified, ! jboolean usemmap) { const char *path = JNU_GetStringPlatformChars(env, name, 0); char *msg = 0; jlong result = 0; int flag = 0; jzfile *zip = 0; if (mode & OPEN_READ) flag |= O_RDONLY; --- 82,99 ---- } JNIEXPORT jlong JNICALL Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name, jint mode, jlong lastModified, ! jboolean usemmap, ! jobjectArray tableAndEntriesByteBuffers) { const char *path = JNU_GetStringPlatformChars(env, name, 0); char *msg = 0; jlong result = 0; + jobject tableByteBuffer; + jobject entriesByteBuffer; int flag = 0; jzfile *zip = 0; if (mode & OPEN_READ) flag |= O_RDONLY;
*** 118,127 **** --- 121,139 ---- zip = ZIP_Put_In_Cache0(path, zfd, &msg, lastModified, usemmap); } if (zip != 0) { result = ptr_to_jlong(zip); + if (tableAndEntriesByteBuffers != NULL) { + tableByteBuffer = (*env)->NewDirectByteBuffer(env, zip->table, (jlong) zip->tablelen * sizeof(zip->table[0])); + if (tableByteBuffer == NULL) goto finally; + entriesByteBuffer = (*env)->NewDirectByteBuffer(env, zip->entries, (jlong) zip->total * sizeof(zip->entries[0])); + if (tableByteBuffer == NULL) goto finally; + (*env)->SetObjectArrayElement(env, tableAndEntriesByteBuffers, 0, tableByteBuffer); + if ((*env)->ExceptionCheck(env)) goto finally; + (*env)->SetObjectArrayElement(env, tableAndEntriesByteBuffers, 1, entriesByteBuffer); + } } else if (msg != 0) { ThrowZipException(env, msg); free(msg); } else if (errno == ENOMEM) { JNU_ThrowOutOfMemoryError(env, 0);
< prev index next >