From 5f358199788fefb78f5db7791e718480793a77fc Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 15 Sep 2019 11:38:30 -0400 Subject: Don't create filenames that conflict with Windows reserved filenames. --- core/src/main/kotlin/Locations/Location.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'core/src/main/kotlin/Locations') 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 { -- cgit