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.
This commit is contained in:
Ian Lynagh 2022-10-26 19:20:32 +01:00
Родитель 4050801a17
Коммит 0a470b0864
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -14,7 +14,15 @@ public abstract class PathTransformer {
* canonical, absolute, strings and normalises away Unix/Windows differences.
*/
public String fileAsDatabaseString(File file) {
String path;
String path = file.getPath();
// For a /!unknown-binary-location/... path, on Windows
// the standard code wants to normalise it to
// C:/!unknown-binary-location/...
// which is particularly annoying for cross-platform test
// output. We therefore handle it specially here.
if (path.matches("^[/\\\\]!unknown-binary-location[/\\\\].*")) {
return path.replace('\\', '/');
}
if (Boolean.valueOf(Env.systemEnv().get(Var.SEMMLE_PRESERVE_SYMLINKS)))
path = FileUtil.simplifyPath(file);
else
@ -43,4 +51,4 @@ public abstract class PathTransformer {
public static PathTransformer std() {
return DEFAULT_TRANSFORMER;
}
}
}