Skip to content

Commit

Permalink
Use the appropriate extension for in-place conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks committed Oct 12, 2024
1 parent 10eefce commit 05fbd7d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion vgo/src/main/kotlin/com/jzbrooks/vgo/Vgo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.w3c.dom.Document
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.file.Paths
import javax.xml.parsers.DocumentBuilderFactory
import kotlin.math.absoluteValue
import kotlin.math.roundToInt
Expand Down Expand Up @@ -59,7 +60,7 @@ class Vgo(
}
} else {
inputs.zip(inputs) { a, b ->
Pair(File(a), File(b))

}
}.toMap()

Expand All @@ -70,6 +71,24 @@ class Vgo(
return handleFiles(inputOutputMap, writerOptions)
}

private fun pairOutputs(): Map<File, File> {
val inputFiles = options.input.map(::File)
return if (options.output.isNotEmpty()) {
inputFiles.zip(options.output.map(::File)).toMap()
} else {
inputFiles.mapIndexed { index, input ->
if (!input.isDirectory) {
val outputExtension = when (options.format) {
"svg" -> "svg"
"vd" -> "xml"
else -> input.extension
}
val outputFilePath = options.output.dropLastWhile { it != '.' } + outputExtension
}
}.toMap()
}
}

private fun handleFiles(
inputOutputMap: Map<File, File>,
writerOptions: Set<Writer.Option>,
Expand Down

0 comments on commit 05fbd7d

Please sign in to comment.