equal
deleted
inserted
replaced
879 * Opens a zip file for reading. Returns the jzfile object or NULL |
879 * Opens a zip file for reading. Returns the jzfile object or NULL |
880 * if an error occurred. If a zip error occurred then *msg will be |
880 * if an error occurred. If a zip error occurred then *msg will be |
881 * set to the error message text if msg != 0. Otherwise, *msg will be |
881 * set to the error message text if msg != 0. Otherwise, *msg will be |
882 * set to NULL. Caller doesn't need to free the error message. |
882 * set to NULL. Caller doesn't need to free the error message. |
883 */ |
883 */ |
884 JNIEXPORT jzfile * JNICALL |
884 JNIEXPORT jzfile * |
885 ZIP_Open(const char *name, char **pmsg) |
885 ZIP_Open(const char *name, char **pmsg) |
886 { |
886 { |
887 jzfile *file = ZIP_Open_Generic(name, pmsg, O_RDONLY, 0); |
887 jzfile *file = ZIP_Open_Generic(name, pmsg, O_RDONLY, 0); |
888 if (file == NULL && pmsg != NULL && *pmsg != NULL) { |
888 if (file == NULL && pmsg != NULL && *pmsg != NULL) { |
889 free(*pmsg); |
889 free(*pmsg); |
893 } |
893 } |
894 |
894 |
895 /* |
895 /* |
896 * Closes the specified zip file object. |
896 * Closes the specified zip file object. |
897 */ |
897 */ |
898 JNIEXPORT void JNICALL |
898 JNIEXPORT void |
899 ZIP_Close(jzfile *zip) |
899 ZIP_Close(jzfile *zip) |
900 { |
900 { |
901 MLOCK(zfiles_lock); |
901 MLOCK(zfiles_lock); |
902 if (--zip->refs > 0) { |
902 if (--zip->refs > 0) { |
903 /* Still more references so just return */ |
903 /* Still more references so just return */ |
1113 |
1113 |
1114 /* |
1114 /* |
1115 * Returns the zip entry corresponding to the specified name, or |
1115 * Returns the zip entry corresponding to the specified name, or |
1116 * NULL if not found. |
1116 * NULL if not found. |
1117 */ |
1117 */ |
1118 JNIEXPORT jzentry * JNICALL |
1118 JNIEXPORT jzentry * |
1119 ZIP_GetEntry(jzfile *zip, char *name, jint ulen) |
1119 ZIP_GetEntry(jzfile *zip, char *name, jint ulen) |
1120 { |
1120 { |
1121 if (ulen == 0) { |
1121 if (ulen == 0) { |
1122 return ZIP_GetEntry2(zip, name, (jint)strlen(name), JNI_FALSE); |
1122 return ZIP_GetEntry2(zip, name, (jint)strlen(name), JNI_FALSE); |
1123 } |
1123 } |
1236 |
1236 |
1237 /* |
1237 /* |
1238 * Returns the n'th (starting at zero) zip file entry, or NULL if the |
1238 * Returns the n'th (starting at zero) zip file entry, or NULL if the |
1239 * specified index was out of range. |
1239 * specified index was out of range. |
1240 */ |
1240 */ |
1241 JNIEXPORT jzentry * JNICALL |
1241 JNIEXPORT jzentry * |
1242 ZIP_GetNextEntry(jzfile *zip, jint n) |
1242 ZIP_GetNextEntry(jzfile *zip, jint n) |
1243 { |
1243 { |
1244 jzentry *result; |
1244 jzentry *result; |
1245 if (n < 0 || n >= zip->total) { |
1245 if (n < 0 || n >= zip->total) { |
1246 return 0; |
1246 return 0; |
1437 |
1437 |
1438 /* |
1438 /* |
1439 * The current implementation does not support reading an entry that |
1439 * The current implementation does not support reading an entry that |
1440 * has the size bigger than 2**32 bytes in ONE invocation. |
1440 * has the size bigger than 2**32 bytes in ONE invocation. |
1441 */ |
1441 */ |
1442 JNIEXPORT jzentry * JNICALL |
1442 JNIEXPORT jzentry * |
1443 ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP) |
1443 ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP) |
1444 { |
1444 { |
1445 jzentry *entry = ZIP_GetEntry(zip, name, 0); |
1445 jzentry *entry = ZIP_GetEntry(zip, name, 0); |
1446 if (entry) { |
1446 if (entry) { |
1447 *sizeP = (jint)entry->size; |
1447 *sizeP = (jint)entry->size; |
1454 * Reads a zip file entry into the specified byte array |
1454 * Reads a zip file entry into the specified byte array |
1455 * When the method completes, it releases the jzentry. |
1455 * When the method completes, it releases the jzentry. |
1456 * Note: this is called from the separately delivered VM (hotspot/classic) |
1456 * Note: this is called from the separately delivered VM (hotspot/classic) |
1457 * so we have to be careful to maintain the expected behaviour. |
1457 * so we have to be careful to maintain the expected behaviour. |
1458 */ |
1458 */ |
1459 JNIEXPORT jboolean JNICALL |
1459 JNIEXPORT jboolean |
1460 ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname) |
1460 ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname) |
1461 { |
1461 { |
1462 char *msg; |
1462 char *msg; |
1463 char tmpbuf[1024]; |
1463 char tmpbuf[1024]; |
1464 |
1464 |
1513 ZIP_FreeEntry(zip, entry); |
1513 ZIP_FreeEntry(zip, entry); |
1514 |
1514 |
1515 return JNI_TRUE; |
1515 return JNI_TRUE; |
1516 } |
1516 } |
1517 |
1517 |
1518 JNIEXPORT jboolean JNICALL |
1518 JNIEXPORT jboolean |
1519 ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg) |
1519 ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg) |
1520 { |
1520 { |
1521 z_stream strm; |
1521 z_stream strm; |
1522 int i = 0; |
1522 int i = 0; |
1523 memset(&strm, 0, sizeof(z_stream)); |
1523 memset(&strm, 0, sizeof(z_stream)); |