1357 strm.next_out = buf;
1358 strm.avail_out = (uInt)entry->size;
1359
1360 while (count > 0) {
1361 jint n = count > (jlong)sizeof(tmp) ? (jint)sizeof(tmp) : (jint)count;
1362 ZIP_Lock(zip);
1363 n = ZIP_Read(zip, entry, pos, tmp, n);
1364 ZIP_Unlock(zip);
1365 if (n <= 0) {
1366 if (n == 0) {
1367 *msg = "inflateFully: Unexpected end of file";
1368 }
1369 inflateEnd(&strm);
1370 return JNI_FALSE;
1371 }
1372 pos += n;
1373 count -= n;
1374 strm.next_in = (Bytef *)tmp;
1375 strm.avail_in = n;
1376 do {
1377 switch (inflate(&strm, Z_PARTIAL_FLUSH)) {
1378 case Z_OK:
1379 break;
1380 case Z_STREAM_END:
1381 if (count != 0 || strm.total_out != entry->size) {
1382 *msg = "inflateFully: Unexpected end of stream";
1383 inflateEnd(&strm);
1384 return JNI_FALSE;
1385 }
1386 break;
1387 default:
1388 break;
1389 }
1390 } while (strm.avail_in > 0);
1391 }
1392 inflateEnd(&strm);
1393 return JNI_TRUE;
1394 }
1395
1396 /*
1397 * The current implementation does not support reading an entry that
1398 * has the size bigger than 2**32 bytes in ONE invocation.
1399 */
|
1357 strm.next_out = buf;
1358 strm.avail_out = (uInt)entry->size;
1359
1360 while (count > 0) {
1361 jint n = count > (jlong)sizeof(tmp) ? (jint)sizeof(tmp) : (jint)count;
1362 ZIP_Lock(zip);
1363 n = ZIP_Read(zip, entry, pos, tmp, n);
1364 ZIP_Unlock(zip);
1365 if (n <= 0) {
1366 if (n == 0) {
1367 *msg = "inflateFully: Unexpected end of file";
1368 }
1369 inflateEnd(&strm);
1370 return JNI_FALSE;
1371 }
1372 pos += n;
1373 count -= n;
1374 strm.next_in = (Bytef *)tmp;
1375 strm.avail_in = n;
1376 do {
1377 switch (inflate(&strm, Z_FINISH)) {
1378 case Z_STREAM_END:
1379 if (count != 0 || strm.total_out != entry->size) {
1380 *msg = "inflateFully: Unexpected end of stream";
1381 inflateEnd(&strm);
1382 return JNI_FALSE;
1383 }
1384 break;
1385 default:
1386 break;
1387 }
1388 } while (strm.avail_in > 0);
1389 }
1390 inflateEnd(&strm);
1391 return JNI_TRUE;
1392 }
1393
1394 /*
1395 * The current implementation does not support reading an entry that
1396 * has the size bigger than 2**32 bytes in ONE invocation.
1397 */
|