mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Refactor.
This commit is contained in:
parent
7b603c76f4
commit
589c953a9c
1 changed files with 47 additions and 38 deletions
|
@ -34,9 +34,8 @@ public class JarUtils {
|
|||
|
||||
public fun addSingleFile(directory: String, file: IncludedFile, outputStream: ZipOutputStream,
|
||||
expandJarFiles: Boolean, onError: (Exception) -> Unit = DEFAULT_HANDLER) {
|
||||
file.specs.forEach { spec ->
|
||||
val path = spec.toString()
|
||||
spec.toFiles(directory + "/" + file.from).forEach { source ->
|
||||
file.allFromFiles(directory).forEach { source ->
|
||||
val path = source.path
|
||||
if (source.isDirectory) {
|
||||
log(2, "Writing contents of directory $source")
|
||||
|
||||
|
@ -79,7 +78,6 @@ public class JarUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addEntry(inputStream: InputStream, entry: ZipEntry, outputStream: ZipOutputStream,
|
||||
onError: (Exception) -> Unit = DEFAULT_HANDLER) {
|
||||
|
@ -153,6 +151,17 @@ class IncludedFile(val fromOriginal: From, val toOriginal: To, val specs: List<I
|
|||
"files", specs.map { it.toString() }.joinToString(", "),
|
||||
"from", from,
|
||||
"to", to)
|
||||
|
||||
fun allFromFiles(directory: String): List<File> {
|
||||
val result = arrayListOf<File>()
|
||||
specs.forEach { spec ->
|
||||
val path = spec.toString()
|
||||
spec.toFiles(directory + "/" + from).forEach { source ->
|
||||
result.add(source)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class From(override val p: String) : Direction(p)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue