INT-2390 backported INT-2350 and INT-2351 to 2.0.6

This commit is contained in:
Oleg Zhurakousky
2012-01-06 10:52:47 -05:00
parent 575a80f9c0
commit 9babf3d784
9 changed files with 130 additions and 57 deletions

View File

@@ -136,4 +136,24 @@ class FtpSession implements Session {
this.client.makeDirectory(directory);
}
}
public boolean exists(String path) throws IOException {
Assert.hasText(path, "'path' must not be empty");
String currentWorkingPath = this.client.printWorkingDirectory();
Assert.state(currentWorkingPath != null, "working directory cannot be determined, therefore exists check can not be completed");
boolean exists = false;
try {
if (this.client.changeWorkingDirectory(path)){
exists = true;
}
}
finally {
this.client.changeWorkingDirectory(currentWorkingPath);
}
return exists;
}
}