forked from openrs2/openrs2
Signed-off-by: Graham <gpe@openrs2.org>bzip2
parent
cf6e7cf8e7
commit
2b3e9d318a
@ -0,0 +1,24 @@ |
||||
package org.openrs2.compress.cli.pack200 |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.github.ajalt.clikt.parameters.options.option |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdin |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdout |
||||
import com.github.ajalt.clikt.parameters.types.inputStream |
||||
import com.github.ajalt.clikt.parameters.types.outputStream |
||||
import org.openrs2.compress.gzip.Gzip |
||||
import java.util.jar.JarInputStream |
||||
import java.util.jar.Pack200 |
||||
|
||||
public class Pack200Command : CliktCommand(name = "pack200") { |
||||
private val input by option().inputStream().defaultStdin() |
||||
private val output by option().outputStream().defaultStdout() |
||||
|
||||
override fun run() { |
||||
JarInputStream(input).use { jarInput -> |
||||
Gzip.createHeaderlessOutputStream(output).use { gzipOutput -> |
||||
Pack200.newPacker().pack(jarInput, gzipOutput) |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
package org.openrs2.compress.cli.pack200 |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.github.ajalt.clikt.parameters.options.option |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdin |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdout |
||||
import com.github.ajalt.clikt.parameters.types.inputStream |
||||
import com.github.ajalt.clikt.parameters.types.outputStream |
||||
import org.openrs2.compress.gzip.Gzip |
||||
import org.openrs2.util.io.DeterministicJarOutputStream |
||||
import java.util.jar.Pack200 |
||||
|
||||
public class Unpack200Command : CliktCommand(name = "unpack200") { |
||||
private val input by option().inputStream().defaultStdin() |
||||
private val output by option().outputStream().defaultStdout() |
||||
|
||||
override fun run() { |
||||
Gzip.createHeaderlessInputStream(input).use { gzipInput -> |
||||
DeterministicJarOutputStream(output).use { jarOutput -> |
||||
Pack200.newUnpacker().unpack(gzipInput, jarOutput) |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@ |
||||
package org.openrs2.compress.cli.packclass |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.github.ajalt.clikt.parameters.options.option |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdin |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdout |
||||
import com.github.ajalt.clikt.parameters.types.inputStream |
||||
import com.github.ajalt.clikt.parameters.types.outputStream |
||||
import io.netty.buffer.ByteBufAllocator |
||||
import org.openrs2.asm.classpath.ClassPath |
||||
import org.openrs2.asm.io.JarLibraryReader |
||||
import org.openrs2.asm.io.PackClassLibraryWriter |
||||
|
||||
public class PackClassCommand : CliktCommand(name = "packclass") { |
||||
private val input by option().inputStream().defaultStdin() |
||||
private val output by option().outputStream().defaultStdout() |
||||
|
||||
override fun run() { |
||||
val classes = JarLibraryReader.read(input) |
||||
val classPath = ClassPath(ClassLoader.getPlatformClassLoader(), emptyList(), emptyList()) |
||||
PackClassLibraryWriter(ByteBufAllocator.DEFAULT).write(output, classPath, classes) |
||||
} |
||||
} |
@ -0,0 +1,23 @@ |
||||
package org.openrs2.compress.cli.packclass |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.github.ajalt.clikt.parameters.options.option |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdin |
||||
import com.github.ajalt.clikt.parameters.types.defaultStdout |
||||
import com.github.ajalt.clikt.parameters.types.inputStream |
||||
import com.github.ajalt.clikt.parameters.types.outputStream |
||||
import io.netty.buffer.ByteBufAllocator |
||||
import org.openrs2.asm.classpath.ClassPath |
||||
import org.openrs2.asm.io.JarLibraryWriter |
||||
import org.openrs2.asm.io.PackClassLibraryReader |
||||
|
||||
public class UnpackClassCommand : CliktCommand(name = "unpackclass") { |
||||
private val input by option().inputStream().defaultStdin() |
||||
private val output by option().outputStream().defaultStdout() |
||||
|
||||
override fun run() { |
||||
val classes = PackClassLibraryReader(ByteBufAllocator.DEFAULT).read(input) |
||||
val classPath = ClassPath(ClassLoader.getPlatformClassLoader(), emptyList(), emptyList()) |
||||
JarLibraryWriter.write(output, classPath, classes) |
||||
} |
||||
} |
Loading…
Reference in new issue