mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Refactor.
This commit is contained in:
parent
953814982f
commit
14ad4ce733
1 changed files with 14 additions and 16 deletions
|
@ -14,25 +14,23 @@ 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 ->
|
||||||
|
var entry = ins.nextEntry
|
||||||
|
while (entry != null) {
|
||||||
|
val f = File(destDir.path + File.separator + entry.name)
|
||||||
|
if (entry.isDirectory) {
|
||||||
|
f.mkdir()
|
||||||
|
entry = ins.nextEntry
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
private fun extractFile(destDir: File) {
|
kobaltLog(2, " Extracting: $entry to ${f.absolutePath}")
|
||||||
val ins = JarInputStream(inputStream)
|
FileOutputStream(f).use { fos ->
|
||||||
var entry = ins.nextEntry
|
KFiles.copy(ins, fos)
|
||||||
while (entry != null) {
|
}
|
||||||
val f = File(destDir.path + File.separator + entry.name)
|
|
||||||
if (entry.isDirectory) {
|
|
||||||
f.mkdir()
|
|
||||||
entry = ins.nextEntry
|
entry = ins.nextEntry
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kobaltLog(2, " Extracting: $entry to ${f.absolutePath}")
|
|
||||||
FileOutputStream(f).use { fos ->
|
|
||||||
KFiles.copy(ins, fos)
|
|
||||||
}
|
|
||||||
entry = ins.nextEntry
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue