Added addEntry function.
This commit is contained in:
parent
aeb7c74dd6
commit
76079f2d0d
1 changed files with 13 additions and 4 deletions
|
@ -82,10 +82,11 @@ fun reZip3(jarIn: File, srcJar: File, zipOut: File) {
|
||||||
val tmp = Files.createTempFile(MANIFEST, ".tmp").toFile()
|
val tmp = Files.createTempFile(MANIFEST, ".tmp").toFile()
|
||||||
tmp.writeText("Manifest-Version: 1.0\r\nCreated-By: ReZip3\r\nMain-Class: com.beust.kobalt.MainKt\r\n")
|
tmp.writeText("Manifest-Version: 1.0\r\nCreated-By: ReZip3\r\nMain-Class: com.beust.kobalt.MainKt\r\n")
|
||||||
|
|
||||||
val entry = zos.createArchiveEntry(tmp, "META-INF/$MANIFEST")
|
addEntry(zos, tmp, "META-INF/$MANIFEST")
|
||||||
zos.putArchiveEntry(entry)
|
|
||||||
IOUtils.copy(tmp.inputStream(), zos)
|
val kobaltw = File(System.getProperty("user.home") + "/.kobalt/wrapper/dist/kobalt-1.0.60/bin/kobaltw")
|
||||||
zos.closeArchiveEntry()
|
|
||||||
|
addEntry(zos, kobaltw, "bin/${kobaltw.name}")
|
||||||
|
|
||||||
src.close()
|
src.close()
|
||||||
zos.close()
|
zos.close()
|
||||||
|
@ -94,6 +95,14 @@ fun reZip3(jarIn: File, srcJar: File, zipOut: File) {
|
||||||
println("ReZip-3 Time: $time ms")
|
println("ReZip-3 Time: $time ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add an archive entry
|
||||||
|
fun addEntry(zos: ZipArchiveOutputStream, file: File, path: String) {
|
||||||
|
val entry = zos.createArchiveEntry(file, path)
|
||||||
|
zos.putArchiveEntry(entry)
|
||||||
|
IOUtils.copy(file.inputStream(), zos)
|
||||||
|
zos.closeArchiveEntry()
|
||||||
|
}
|
||||||
|
|
||||||
// Look for duplicate entries
|
// Look for duplicate entries
|
||||||
fun entryExists(jarEntries: Enumeration<ZipArchiveEntry>, entry: ZipArchiveEntry): Boolean {
|
fun entryExists(jarEntries: Enumeration<ZipArchiveEntry>, entry: ZipArchiveEntry): Boolean {
|
||||||
for (e in jarEntries) {
|
for (e in jarEntries) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue