public synchronized int copy(LocalSourceFile sourceFile, String remotePath, ScpCommandLine.EscapeMode escapeMode) throws IOException { engine.cleanSlate(); try { startCopy(sourceFile, remotePath, escapeMode); } finally { engine.exit(); } return engine.getExitStatus(); }
public synchronized int copy(String sourcePath, LocalDestFile targetFile, ScpCommandLine.EscapeMode escapeMode) throws IOException { engine.cleanSlate(); try { startCopy(sourcePath, targetFile, escapeMode); } finally { engine.exit(); } return engine.getExitStatus(); }
@Override public void upload(LocalSourceFile localFile, String remotePath) throws IOException { newSCPUploadClient().copy(localFile, remotePath); }
private void startCopy(String sourcePath, LocalDestFile targetFile, ScpCommandLine.EscapeMode escapeMode) throws IOException { ScpCommandLine commandLine = ScpCommandLine.with(ScpCommandLine.Arg.SOURCE) .and(ScpCommandLine.Arg.QUIET) .and(ScpCommandLine.Arg.PRESERVE_TIMES) .and(ScpCommandLine.Arg.RECURSIVE, recursiveMode) .and(ScpCommandLine.Arg.LIMIT, String.valueOf(bandwidthLimit), (bandwidthLimit > 0)); commandLine.withPath(sourcePath, escapeMode); engine.execSCPWith(commandLine); engine.signal("Start status OK"); String msg = engine.readMessage(); do { process(engine.getTransferListener(), null, msg, targetFile); } while (!(msg = engine.readMessage()).isEmpty()); }
private void startCopy(LocalSourceFile sourceFile, String targetPath, ScpCommandLine.EscapeMode escapeMode) throws IOException { ScpCommandLine commandLine = ScpCommandLine.with(ScpCommandLine.Arg.SINK) .and(ScpCommandLine.Arg.RECURSIVE) .and(ScpCommandLine.Arg.PRESERVE_TIMES, sourceFile.providesAtimeMtime()) .and(ScpCommandLine.Arg.LIMIT, String.valueOf(bandwidthLimit), (bandwidthLimit > 0)); commandLine.withPath(targetPath, escapeMode); engine.execSCPWith(commandLine); engine.check("Start status OK"); process(engine.getTransferListener(), sourceFile); }
private void sendDirectory(TransferListener listener, LocalSourceFile f) throws IOException { preserveTimeIfPossible(f); engine.sendMessage("D0" + getPermString(f) + " 0 " + f.getName()); for (LocalSourceFile child : f.getChildren(uploadFilter)) process(listener, child); engine.sendMessage("E"); }
@Override public void download(String remotePath, LocalDestFile localFile) throws IOException { newSCPDownloadClient().copy(remotePath, localFile); }
private SCPEngine newSCPEngine() { return new SCPEngine(sessionFactory, getTransferListener(), loggerFactory); }
public SCPUploadClient newSCPUploadClient() { return new SCPUploadClient(newSCPEngine(), bandwidthLimit); }
public SCPDownloadClient newSCPDownloadClient() { return new SCPDownloadClient(newSCPEngine(), bandwidthLimit); }
/** Upload a local file from {@code localFile} to {@code targetPath} on the remote host. */ public synchronized int copy(LocalSourceFile sourceFile, String remotePath) throws IOException { return copy(sourceFile, remotePath, ScpCommandLine.EscapeMode.SingleQuote); }
static ScpCommandLine with(Arg name, String value, boolean accept) { ScpCommandLine commandLine = new ScpCommandLine(); commandLine.addArgument(name, value, accept); return commandLine; }
/** Download a file from {@code sourcePath} on the connected host to {@code targetPath} locally. */ public synchronized int copy(String sourcePath, LocalDestFile targetFile) throws IOException { return copy(sourcePath, targetFile, ScpCommandLine.EscapeMode.NoEscape); }
ScpCommandLine and(Arg name, String value) { addArgument(name, value, true); return this; }
static ScpCommandLine with(Arg name) { return with(name, null, true); }
@Override public void upload(String localPath, String remotePath) throws IOException { newSCPUploadClient().copy(new FileSystemFile(localPath), remotePath); }
ScpCommandLine and(Arg name, String value, boolean accept) { addArgument(name, value, accept); return this; }
static ScpCommandLine with(Arg name, String value) { return with(name, value, true); }
ScpCommandLine and(Arg name) { addArgument(name, null, true); return this; }
ScpCommandLine and(Arg name, boolean accept) { addArgument(name, null, accept); return this; }