1424 this.e = Objects.requireNonNull(e, "Zip entry is null");
1425 this.crc = new CRC32();
1426 }
1427
1428 @Override
1429 public void write(byte b[], int off, int len)
1430 throws IOException {
1431 super.write(b, off, len);
1432 crc.update(b, off, len);
1433 }
1434
1435 @Override
1436 public void close() throws IOException {
1437 if (isClosed)
1438 return;
1439 isClosed = true;
1440 finish();
1441 e.size = def.getBytesRead();
1442 e.csize = def.getBytesWritten();
1443 e.crc = crc.getValue();
1444 }
1445 }
1446
1447 private InputStream getInputStream(Entry e)
1448 throws IOException
1449 {
1450 InputStream eis = null;
1451
1452 if (e.type == Entry.NEW) {
1453 // now bytes & file is uncompressed.
1454 if (e.bytes != null)
1455 return new ByteArrayInputStream(e.bytes);
1456 else if (e.file != null)
1457 return Files.newInputStream(e.file);
1458 else
1459 throw new ZipException("update entry data is missing");
1460 } else if (e.type == Entry.FILECH) {
1461 // FILECH result is un-compressed.
1462 eis = Files.newInputStream(e.file);
1463 // TBD: wrap to hook close()
|
1424 this.e = Objects.requireNonNull(e, "Zip entry is null");
1425 this.crc = new CRC32();
1426 }
1427
1428 @Override
1429 public void write(byte b[], int off, int len)
1430 throws IOException {
1431 super.write(b, off, len);
1432 crc.update(b, off, len);
1433 }
1434
1435 @Override
1436 public void close() throws IOException {
1437 if (isClosed)
1438 return;
1439 isClosed = true;
1440 finish();
1441 e.size = def.getBytesRead();
1442 e.csize = def.getBytesWritten();
1443 e.crc = crc.getValue();
1444 releaseDeflater(def);
1445 }
1446 }
1447
1448 private InputStream getInputStream(Entry e)
1449 throws IOException
1450 {
1451 InputStream eis = null;
1452
1453 if (e.type == Entry.NEW) {
1454 // now bytes & file is uncompressed.
1455 if (e.bytes != null)
1456 return new ByteArrayInputStream(e.bytes);
1457 else if (e.file != null)
1458 return Files.newInputStream(e.file);
1459 else
1460 throw new ZipException("update entry data is missing");
1461 } else if (e.type == Entry.FILECH) {
1462 // FILECH result is un-compressed.
1463 eis = Files.newInputStream(e.file);
1464 // TBD: wrap to hook close()
|