From c185e420971950747535e98f96a12e480159dd83 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 26 Nov 2019 18:02:56 +0100 Subject: Fix FileWriter --- core/src/main/kotlin/renderers/FileWriter.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core/src/main/kotlin') diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt index 319926dd..9ee02b4b 100644 --- a/core/src/main/kotlin/renderers/FileWriter.kt +++ b/core/src/main/kotlin/renderers/FileWriter.kt @@ -5,16 +5,17 @@ import java.io.IOException import java.nio.file.Paths class FileWriter(val root: String, val extension: String){ - private val createdFiles: MutableMap = mutableMapOf() + private val createdFiles: MutableSet = mutableSetOf() fun write(path: String, text: String, ext: String = extension){ - if (createdFiles.getOrDefault(path, 0) > 0) { + if (createdFiles.contains(path)) { println("ERROR. An attempt to write $root/$path several times!") return } + createdFiles.add(path) try { - println("Writing $root/$path$ext") +// println("Writing $root/$path$ext") val dir = Paths.get(root, path.dropLastWhile { it != '/' }).toFile() dir.mkdirsOrFail() Paths.get(root, "$path$ext").toFile().writeText(text) -- cgit