aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-11-26 18:02:56 +0100
committerKamil Doległo <kamilok1965@interia.pl>2019-11-26 18:20:23 +0100
commitc185e420971950747535e98f96a12e480159dd83 (patch)
tree7e29907892eb43094432517a192f9f20c2201059
parent7e87c8ac4b7b3987df1722d7b9a6d3b2c5b169a4 (diff)
downloaddokka-c185e420971950747535e98f96a12e480159dd83.tar.gz
dokka-c185e420971950747535e98f96a12e480159dd83.tar.bz2
dokka-c185e420971950747535e98f96a12e480159dd83.zip
Fix FileWriter
-rw-r--r--core/src/main/kotlin/renderers/FileWriter.kt7
1 files changed, 4 insertions, 3 deletions
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<String, Int> = mutableMapOf()
+ private val createdFiles: MutableSet<String> = 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)