SshFxpRead msg = new SshFxpRead(requestId, handle, offset,
new UnsignedInteger32(len));
sendMessage(msg);
try {
SubsystemMessage reply = messageStore.getMessage(requestId);
if (reply instanceof SshFxpData) {
byte[] msgdata = ((SshFxpData) reply).getData();
System.arraycopy(msgdata, 0, output, off, msgdata.length);
return msgdata.length;
} else if (reply instanceof SshFxpStatus) {
SshFxpStatus status = (SshFxpStatus) reply;
if (status.getErrorCode().intValue() == SshFxpStatus.STATUS_FX_EOF) {
return -1;
} else {
throw new IOException(((SshFxpStatus) reply).getErrorMessage());
}
} else {
throw new IOException("Unexpected server response " +
reply.getMessageName());
}
} catch (InterruptedException ex) {
throw new IOException("The thread was interrupted");
}
}