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