1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Refactor.

This commit is contained in:
Cedric Beust 2017-02-16 15:45:58 -08:00
parent 953814982f
commit 14ad4ce733

View file

@ -14,11 +14,8 @@ interface InputStreamJarTemplate : ITemplate {
val inputStream: InputStream val inputStream: InputStream
override fun generateTemplate(args: Args, classLoader: ClassLoader) { override fun generateTemplate(args: Args, classLoader: ClassLoader) {
extractFile(File(".")) val destDir = File(".")
} JarInputStream(inputStream).use { ins ->
private fun extractFile(destDir: File) {
val ins = JarInputStream(inputStream)
var entry = ins.nextEntry var entry = ins.nextEntry
while (entry != null) { while (entry != null) {
val f = File(destDir.path + File.separator + entry.name) val f = File(destDir.path + File.separator + entry.name)
@ -36,6 +33,7 @@ interface InputStreamJarTemplate : ITemplate {
} }
} }
} }
}
abstract class ResourceJarTemplate(jarName: String, val classLoader: ClassLoader) : InputStreamJarTemplate { abstract class ResourceJarTemplate(jarName: String, val classLoader: ClassLoader) : InputStreamJarTemplate {
override val inputStream : InputStream = classLoader.getResource(jarName).openConnection().inputStream override val inputStream : InputStream = classLoader.getResource(jarName).openConnection().inputStream