* Tries to create a directory path on the target system
* @param path to create
* @param connnection to use
*/
private void makePath(String path, Session session) throws IOException {
ChannelExec channel = null;
String trimmed = path;
try {
while(trimmed.length() > 0 && trimmed.charAt(trimmed.length()-1) == fileSeparator)
trimmed = trimmed.substring(0,trimmed.length()-1);
if(trimmed.length() == 0 || checkExistence(trimmed,session)) {
return;
}
int nextSlash = trimmed.lastIndexOf(fileSeparator);
if(nextSlash > 0) {
String parent = trimmed.substring(0,nextSlash);
makePath(parent,session);
}
channel = getExecChannel(session);
String mkdir = replaceArgument( createDirCommand, trimmed);
Message.debug("SShRepository: trying to create path: " + mkdir);
channel.setCommand(mkdir);
StringBuffer stdOut = new StringBuffer();
StringBuffer stdErr = new StringBuffer();
readSessionOutput(channel,stdOut,stdErr);
} finally {
if(channel != null)
channel.disconnect();
}
}