Convert DeterministicJarOutputStream to Kotlin

master
Graham 5 years ago
parent 72db700534
commit caaa53095d
  1. 28
      util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.java
  2. 23
      util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt

@ -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);
}
}

@ -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)
}
}
Loading…
Cancel
Save