| Method from com.sshtools.daemon.scp.ScpServer Detail: |
public boolean allocatePseudoTerminal(String term,
int cols,
int rows,
int width,
int height,
String modes) {
return false;
}
|
public boolean createProcess(String command,
Map environment) throws IOException {
log.info("Creating ScpServer");
if (nfs == null) {
throw new IOException(
"NativeFileSystem was not instantiated. Please check logs");
}
scp(command.substring(4));
return true;
}
|
public String getDefaultTerminalProvider() {
return null;
}
|
public InputStream getInputStream() throws IOException {
return in;
}
|
public OutputStream getOutputStream() throws IOException {
return out;
}
|
public InputStream getStderrInputStream() {
return err;
}
|
public void kill() {
log.info("Killing ScpServer");
try {
if (pipeIn != null) {
pipeIn.close();
}
} catch (IOException ioe) {
}
try {
if (pipeOut != null) {
pipeOut.close();
}
} catch (IOException ioe) {
}
try {
if (pipeErr != null) {
pipeErr.close();
}
} catch (IOException ioe) {
}
}
|
public void run() {
log.debug("Running ScpServer thread");
try {
if (from) {
log.info("From mode");
try {
waitForResponse();
// Build a string pattern that may be used to match wildcards
StringPattern sp = new StringPattern(destination);
/*If this looks like a wildcard, then attempt a simple expansion.
* This only work for the base part of the file name at the moment
*/
if (sp.hasWildcard()) {
log.debug("Path contains wildcard");
String base = destination;
String dir = ".";
int idx = base.lastIndexOf('/");
if (idx != -1) {
if (idx > 0) {
dir = base.substring(0, idx);
}
base = base.substring(idx + 1);
}
log.debug("Looking for matches in " + dir + " for " +
base);
sp = new StringPattern(base);
byte[] handle = null;
try {
handle = nfs.openDirectory(dir);
SftpFile[] files = nfs.readDirectory(handle);
for (int i = 0; i < files.length; i++) {
log.debug("Testing for match against " +
files[i].getFilename());
if (sp.matches(files[i].getFilename())) {
log.debug("Matched");
writeFileToRemote(dir + "/" +
files[i].getFilename());
} else {
log.debug("No match");
}
}
} finally {
if (handle != null) {
try {
nfs.closeFile(handle);
} catch (Exception e) {
}
}
}
} else {
log.debug("No wildcards");
writeFileToRemote(destination);
}
log.debug("File transfers complete");
} catch (FileNotFoundException fnfe) {
log.error(fnfe);
writeError(fnfe.getMessage(), true);
throw new IOException(fnfe.getMessage());
} catch (PermissionDeniedException pde) {
log.error(pde);
writeError(pde.getMessage(), true);
throw new IOException(pde.getMessage());
} catch (InvalidHandleException ihe) {
log.error(ihe);
writeError(ihe.getMessage(), true);
throw new IOException(ihe.getMessage());
} catch (IOException ioe) {
log.error(ioe);
writeError(ioe.getMessage(), true);
throw new IOException(ioe.getMessage());
}
} else {
log.info("To mode");
readFromRemote(destination);
}
} catch (Throwable t) {
t.printStackTrace();
log.error(t);
exitCode = 1;
}
//
log.debug("ScpServer stopped, notify block on waitForExitCode().");
synchronized (this) {
notify();
}
}
|
public void start() throws IOException {
log.debug("Starting ScpServer thread");
scpServerThread = SshThread.getCurrentThread().cloneThread(this,
"ScpServer");
scpServerThread.start();
}
|
public boolean stillActive() {
return false;
}
|
public boolean supportsPseudoTerminal(String term) {
return false;
}
|
public int waitForExitCode() {
try {
synchronized (this) {
wait();
}
} catch (InterruptedException ie) {
}
log.debug("Returning exit code of " + exitCode);
return exitCode;
}
|