| 559 | } |
| 560 | |
| 561 | fun zeroCompressArchive(source: Path, destination: Path) { |
| 562 | ZipInputStream(Files.newInputStream(source).buffered()).use { input -> |
| 563 | ZipOutputStream(Files.newOutputStream(destination).buffered()).use { output -> |
| 564 | while (true) { |
| 565 | val entry = input.nextEntry ?: break |
| 566 | val bytes = if (entry.isDirectory) ByteArray(0) else input.readBytes() |
| 567 | val crc = CRC32().apply { update(bytes) }.value |
| 568 | |
| 569 | val outputEntry = |
| 570 | ZipEntry(entry.name).apply { |
| 571 | comment = entry.comment |
| 572 | extra = entry.extra |
| 573 | method = ZipEntry.STORED |
| 574 | size = bytes.size.toLong() |
| 575 | compressedSize = bytes.size.toLong() |
| 576 | this.crc = crc |
| 577 | if (entry.time >= 0) { |
| 578 | time = entry.time |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | output.putNextEntry(outputEntry) |
| 583 | if (!entry.isDirectory) { |
| 584 | output.write(bytes) |
| 585 | } |
| 586 | output.closeEntry() |
| 587 | input.closeEntry() |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | fun validateZeroCompressedArchive(source: Path, destination: Path) { |
| 594 | ZipFile(source.toFile()).use { sourceZip -> |
no test coverage detected