MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / zeroCompressArchive

Function zeroCompressArchive

build.gradle.kts:561–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561fun 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
593fun validateZeroCompressedArchive(source: Path, destination: Path) {
594 ZipFile(source.toFile()).use { sourceZip ->

Callers 1

zeroCompressMavenRepoFunction · 0.85

Calls 4

applyMethod · 0.65
writeMethod · 0.65
newInputStreamMethod · 0.45
newOutputStreamMethod · 0.45

Tested by

no test coverage detected