mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -07:00
Minor refactorings.
This commit is contained in:
parent
640fa93d47
commit
11ed432ea2
2 changed files with 13 additions and 4 deletions
|
@ -33,6 +33,14 @@ class Io(val dryRun: Boolean = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun rename(from: File, to: File) {
|
||||||
|
log("rename $from $to")
|
||||||
|
moveFile(from, to.parentFile)
|
||||||
|
if (from.name != to.name) {
|
||||||
|
File(to, from.name).renameTo(to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun copyDirectory(from: File, toDir: File) {
|
fun copyDirectory(from: File, toDir: File) {
|
||||||
log("cp -r $from $toDir")
|
log("cp -r $from $toDir")
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,10 @@ public class JarUtils {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun extractJarFile(jarFile: File, destDir: File) {
|
fun extractJarFile(file: File, destDir: File) = extractZipFile(JarFile(file), destDir)
|
||||||
val jar = JarFile(jarFile)
|
|
||||||
val enumEntries = jar.entries()
|
fun extractZipFile(zipFile: ZipFile, destDir: File) {
|
||||||
|
val enumEntries = zipFile.entries()
|
||||||
while (enumEntries.hasMoreElements()) {
|
while (enumEntries.hasMoreElements()) {
|
||||||
val file = enumEntries.nextElement()
|
val file = enumEntries.nextElement()
|
||||||
val f = File(destDir.path + File.separator + file.name)
|
val f = File(destDir.path + File.separator + file.name)
|
||||||
|
@ -134,7 +135,7 @@ public class JarUtils {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
jar.getInputStream(file).use { ins ->
|
zipFile.getInputStream(file).use { ins ->
|
||||||
f.parentFile.mkdirs()
|
f.parentFile.mkdirs()
|
||||||
FileOutputStream(f).use { fos ->
|
FileOutputStream(f).use { fos ->
|
||||||
while (ins.available() > 0) {
|
while (ins.available() > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue