Fix filename pattern building under Windows

This commit is contained in:
Ilya Chernikov
2019-10-11 08:13:05 +02:00
parent dc1874af3c
commit 9bf46cf435
@@ -55,7 +55,7 @@ fun ClassLoader.forAllMatchingFiles(namePattern: String, body: (String, InputStr
internal val wildcardChars = "*?".toCharArray()
internal val patternCharsToEscape = ".*?+()[]^\${}|".toCharArray().also { assert(wildcardChars.all { wc -> it.contains(wc) }) }
private fun Char.escape(): String = (if (patternCharsToEscape.contains(this)) "\\" else "") + this
private fun Char.escape(): String = (if (this == '\\' || patternCharsToEscape.contains(this)) "\\" else "") + this
internal val pathSeparatorChars = "/".let { if (File.separatorChar == '/') it else it + File.separator }.toCharArray()
internal val pathElementPattern = if (File.separatorChar == '/') "[^/]*" else "[^/${File.separatorChar.escape()}]*"