From caaa53095d88184bcca42a792dab90e601f7faf2 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 15 Dec 2019 16:53:44 +0000 Subject: [PATCH] Convert DeterministicJarOutputStream to Kotlin --- .../util/io/DeterministicJarOutputStream.java | 28 ------------------- .../util/io/DeterministicJarOutputStream.kt | 23 +++++++++++++++ 2 files changed, 23 insertions(+), 28 deletions(-) delete mode 100644 util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.java create mode 100644 util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt diff --git a/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.java b/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.java deleted file mode 100644 index 118bb28b23..0000000000 --- a/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.java +++ /dev/null @@ -1,28 +0,0 @@ -package dev.openrs2.util.io; - -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.attribute.FileTime; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; - -public final class DeterministicJarOutputStream extends JarOutputStream { - private static final FileTime UNIX_EPOCH = FileTime.fromMillis(0); - - public DeterministicJarOutputStream(OutputStream out) throws IOException { - super(out); - } - - public DeterministicJarOutputStream(OutputStream out, Manifest man) throws IOException { - super(out, man); - } - - @Override - public void putNextEntry(ZipEntry ze) throws IOException { - ze.setCreationTime(UNIX_EPOCH); - ze.setLastAccessTime(UNIX_EPOCH); - ze.setLastModifiedTime(UNIX_EPOCH); - super.putNextEntry(ze); - } -} diff --git a/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt b/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt new file mode 100644 index 0000000000..ce2e0bc7ab --- /dev/null +++ b/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt @@ -0,0 +1,23 @@ +package dev.openrs2.util.io + +import java.io.OutputStream +import java.nio.file.attribute.FileTime +import java.util.jar.JarOutputStream +import java.util.jar.Manifest +import java.util.zip.ZipEntry + +class DeterministicJarOutputStream : JarOutputStream { + constructor(out: OutputStream) : super(out) + constructor(out: OutputStream, man: Manifest) : super(out, man) + + override fun putNextEntry(ze: ZipEntry) { + ze.creationTime = UNIX_EPOCH + ze.lastAccessTime = UNIX_EPOCH + ze.lastModifiedTime = UNIX_EPOCH + super.putNextEntry(ze) + } + + companion object { + private val UNIX_EPOCH = FileTime.fromMillis(0) + } +}