aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Locations
diff options
context:
space:
mode:
authorDan <github@drmoose.net>2019-09-15 11:38:30 -0400
committerKamil Doległo <kamilok1965@interia.pl>2019-10-29 15:48:52 +0100
commit5f358199788fefb78f5db7791e718480793a77fc (patch)
tree5c9644becc60a5427efa110d258cba960474c0dd /core/src/main/kotlin/Locations
parenteec585065fa1865bd8cee188b94634f1c9a90c95 (diff)
downloaddokka-5f358199788fefb78f5db7791e718480793a77fc.tar.gz
dokka-5f358199788fefb78f5db7791e718480793a77fc.tar.bz2
dokka-5f358199788fefb78f5db7791e718480793a77fc.zip
Don't create filenames that conflict with Windows reserved filenames.
Diffstat (limited to 'core/src/main/kotlin/Locations')
-rw-r--r--core/src/main/kotlin/Locations/Location.kt4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/src/main/kotlin/Locations/Location.kt b/core/src/main/kotlin/Locations/Location.kt
index 63c9b913..2ad6b652 100644
--- a/core/src/main/kotlin/Locations/Location.kt
+++ b/core/src/main/kotlin/Locations/Location.kt
@@ -57,11 +57,13 @@ fun relativePathToNode(node: DocumentationNode): String {
}
+private val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out")
+
fun identifierToFilename(path: String): String {
if (path.isEmpty()) return "--root--"
val escaped = path.replace('<', '-').replace('>', '-')
val lowercase = escaped.replace("[A-Z]".toRegex()) { matchResult -> "-" + matchResult.value.toLowerCase() }
- return if (lowercase == "index") "--index--" else lowercase
+ return if (lowercase in reservedFilenames) "--$lowercase--" else lowercase
}
fun NodeLocationAwareGenerator.relativePathToLocation(owner: DocumentationNode, node: DocumentationNode): String {