Don't set 'user.dir' if the working directory could not be set.
This commit is contained in:
@@ -32,27 +32,26 @@ public class DefaultProcess implements Process {
|
|||||||
|
|
||||||
public File getWorkingDirectory() throws NativeException {
|
public File getWorkingDirectory() throws NativeException {
|
||||||
FunctionResult result = new FunctionResult();
|
FunctionResult result = new FunctionResult();
|
||||||
String dir;
|
|
||||||
synchronized (workingDirectoryLock) {
|
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);
|
||||||
}
|
}
|
||||||
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 {
|
public void setWorkingDirectory(File directory) throws NativeException {
|
||||||
FunctionResult result = new FunctionResult();
|
FunctionResult result = new FunctionResult();
|
||||||
synchronized (workingDirectoryLock) {
|
synchronized (workingDirectoryLock) {
|
||||||
PosixProcessFunctions.setWorkingDirectory(directory.getAbsolutePath(), result);
|
PosixProcessFunctions.setWorkingDirectory(directory.getAbsolutePath(), result);
|
||||||
|
if (result.isFailed()) {
|
||||||
|
throw new NativeException(String.format("Could not set process working directory: %s",
|
||||||
|
result.getMessage()));
|
||||||
|
}
|
||||||
System.setProperty("user.dir", directory.getAbsolutePath());
|
System.setProperty("user.dir", directory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
if (result.isFailed()) {
|
|
||||||
throw new NativeException(String.format("Could not set process working directory: %s",
|
|
||||||
result.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnvironmentVariable(String name) throws NativeException {
|
public String getEnvironmentVariable(String name) throws NativeException {
|
||||||
|
|||||||
Reference in New Issue
Block a user