Don't set 'user.dir' if the working directory could not be set.

This commit is contained in:
Adam Murdoch
2013-02-07 18:04:44 +11:00
parent 6cab15ece4
commit 0c5d0dfe80

View File

@@ -32,27 +32,26 @@ public class DefaultProcess implements Process {
public File getWorkingDirectory() throws NativeException {
FunctionResult result = new FunctionResult();
String dir;
synchronized (workingDirectoryLock) {
dir = PosixProcessFunctions.getWorkingDirectory(result);
}
String dir = PosixProcessFunctions.getWorkingDirectory(result);
if (result.isFailed()) {
throw new NativeException(String.format("Could not get process working directory: %s",
result.getMessage()));
}
return new File(dir);
}
}
public void setWorkingDirectory(File directory) throws NativeException {
FunctionResult result = new FunctionResult();
synchronized (workingDirectoryLock) {
PosixProcessFunctions.setWorkingDirectory(directory.getAbsolutePath(), result);
System.setProperty("user.dir", directory.getAbsolutePath());
}
if (result.isFailed()) {
throw new NativeException(String.format("Could not set process working directory: %s",
result.getMessage()));
}
System.setProperty("user.dir", directory.getAbsolutePath());
}
}
public String getEnvironmentVariable(String name) throws NativeException {