/* * (non-Javadoc) * * @see * org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer * #openStreams() */ protected void openStreams() throws IncomingFileTransferException { try { // Set input stream from local file final URL url = getRemoteFileURL(); this.username = url.getUserInfo(); scpUtil = new ScpUtil(this); final Session s = scpUtil.getSession(); s.connect(); final String command = SCP_COMMAND + scpUtil.trimTargetFile(url.getPath()); channel = s.openChannel(SCP_EXEC); ((ChannelExec) channel).setCommand(command); channel.connect(); final InputStream ins = channel.getInputStream(); responseStream = channel.getOutputStream(); scpUtil.sendZeroToStream(responseStream); final int c = checkAck(ins); if (c != 'C') throw new IOException(Messages.ScpRetrieveFileTransfer_EXCEPTION_SCP_PROTOCOL); // read '0644 ' final byte[] buf = new byte[1024]; ins.read(buf, 0, 5); setFileLength(readFileSize(ins, buf)); readFileName(ins, buf); // set input stream for reading rest of file remoteFileContents = ins; scpUtil.sendZeroToStream(responseStream); fireReceiveStartEvent(); } catch (final Exception e) { channel = null; username = null; throw new IncomingFileTransferException( NLS.bind( Messages.ScpRetrieveFileTransfer_EXCEPTION_CONNECTING, getRemoteFileURL().toString()), e); } }