Skip to content

Commit 0a470b0

Browse files
committed
Kotlin: Handle /!unknown-binary-location/... paths specially on Windows
The standard code wants to normalise it to C:/!unknown-binary-location/... which is particularly annoying for cross-platform test output.
1 parent 4050801 commit 0a470b0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

java/kotlin-extractor/src/main/java/com/semmle/util/trap/pathtransformers/PathTransformer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ public abstract class PathTransformer {
1414
* canonical, absolute, strings and normalises away Unix/Windows differences.
1515
*/
1616
public String fileAsDatabaseString(File file) {
17-
String path;
17+
String path = file.getPath();
18+
// For a /!unknown-binary-location/... path, on Windows
19+
// the standard code wants to normalise it to
20+
// C:/!unknown-binary-location/...
21+
// which is particularly annoying for cross-platform test
22+
// output. We therefore handle it specially here.
23+
if (path.matches("^[/\\\\]!unknown-binary-location[/\\\\].*")) {
24+
return path.replace('\\', '/');
25+
}
1826
if (Boolean.valueOf(Env.systemEnv().get(Var.SEMMLE_PRESERVE_SYMLINKS)))
1927
path = FileUtil.simplifyPath(file);
2028
else
@@ -43,4 +51,4 @@ public File canonicalFile(String path) {
4351
public static PathTransformer std() {
4452
return DEFAULT_TRANSFORMER;
4553
}
46-
}
54+
}

0 commit comments

Comments
 (0)