[wpilibj] Filesystem.getDeployDirectory(): Strip JNI path from user.dir (#5317)

Fixes
https://www.chiefdelphi.com/t/filesystem-getdeploydirectory-returning-wrong-location-how-to-fix/427292
when unit tests are run with VS Code's java test runner due to VS Code
extension setting working directory which changes user.dir.
This commit is contained in:
sciencewhiz
2023-05-12 21:26:52 -07:00
committed by GitHub
parent 26cc43bee1
commit 258b7cc48b

View File

@@ -23,7 +23,13 @@ public final class Filesystem {
* @return The current working directory (launch directory)
*/
public static File getLaunchDirectory() {
return new File(System.getProperty("user.dir")).getAbsoluteFile();
// workaround for
// https://www.chiefdelphi.com/t/filesystem-getdeploydirectory-returning-wrong-location-how-to-fix/427292
String path =
System.getProperty("user.dir")
.replace(
File.separator + "build" + File.separator + "jni" + File.separator + "release", "");
return new File(path).getAbsoluteFile();
}
/**