@@ -29,7 +29,6 @@ internal fun OutputStream.createZipFile(contents: Path) =
29
29
zipFile(file.toFile(), zipOutputStream)
30
30
}
31
31
}
32
- zipOutputStream.flush()
33
32
}
34
33
35
34
/* *
@@ -60,17 +59,8 @@ private fun zipDirectory(
60
59
lastAccessTime = FileTime .fromMillis(0 )
61
60
}
62
61
zos.putNextEntry(zipEntry)
63
- val bis =
64
- BufferedInputStream (
65
- FileInputStream (file),
66
- )
67
- var bytesRead: Long = 0
68
- val bytesIn = ByteArray (BUFFER_SIZE )
69
- var read: Int
70
- while ((bis.read(bytesIn).also { read = it }) != - 1 ) {
71
- zos.write(bytesIn, 0 , read)
72
- bytesRead + = read.toLong()
73
- }
62
+ BufferedInputStream (FileInputStream (file))
63
+ .use { it.copyTo(zos) }
74
64
zos.closeEntry()
75
65
}
76
66
}
@@ -96,20 +86,7 @@ private fun zipFile(
96
86
lastAccessTime = FileTime .fromMillis(0 )
97
87
}
98
88
zos.putNextEntry(zipEntry)
99
- val bis =
100
- BufferedInputStream (
101
- FileInputStream (
102
- file,
103
- ),
104
- )
105
- var bytesRead: Long = 0
106
- val bytesIn = ByteArray (BUFFER_SIZE )
107
- var read: Int
108
- while ((bis.read(bytesIn).also { read = it }) != - 1 ) {
109
- zos.write(bytesIn, 0 , read)
110
- bytesRead + = read.toLong()
111
- }
89
+ BufferedInputStream (FileInputStream (file))
90
+ .use { it.copyTo(zos) }
112
91
zos.closeEntry()
113
92
}
114
-
115
- private const val BUFFER_SIZE = 8192
0 commit comments