SshSftpFile sftpDest = (SshSftpFile) dest;
if (sftpDest.getConnection() == getConnection()) {
try {
connection.getSharedSftpClient().rename(getSftpPath(), sftpDest.getSftpPath());
} catch (IOException e) {
throw new RuntimeIOException(format("Cannot move/rename file/directory %s to %s", this, dest), e);
}
} else {
throw new RuntimeIOException(format(
"Cannot move/rename ssh:%s: file/directory %s to file/directory %s because it is in a different connection",
connection.sshConnectionType.toString().toLowerCase(), this, dest));
}
} else {
throw new RuntimeIOException(format("Cannot move/rename ssh:%s: file/directory %s to non-ssh:%s: file/directory %s",
connection.sshConnectionType.toString().toLowerCase(), this, connection.sshConnectionType.toString().toLowerCase(), dest));
}
}