in sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommand.java [77:154]
public ScpCommand(ChannelSession channelSession, String command,
CloseableExecutorService executorService,
int sendSize, int receiveSize,
ScpFileOpener fileOpener, ScpTransferEventListener eventListener) {
super(command, executorService);
this.channelSession = Objects.requireNonNull(channelSession, "No channel session provided");
if (sendSize < ScpHelper.MIN_SEND_BUFFER_SIZE) {
throw new IllegalArgumentException("<ScpCommmand>(" + command + ") send buffer size "
+ "(" + sendSize + ") below minimum required "
+ "(" + ScpHelper.MIN_SEND_BUFFER_SIZE + ")");
}
sendBufferSize = sendSize;
if (receiveSize < ScpHelper.MIN_RECEIVE_BUFFER_SIZE) {
throw new IllegalArgumentException("<ScpCommmand>(" + command + ") receive buffer size "
+ "(" + sendSize + ") below minimum required "
+ "(" + ScpHelper.MIN_RECEIVE_BUFFER_SIZE + ")");
}
receiveBufferSize = receiveSize;
opener = (fileOpener == null) ? DefaultScpFileOpener.INSTANCE : fileOpener;
listener = (eventListener == null) ? ScpTransferEventListener.EMPTY : eventListener;
boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) {
log.debug("Executing command {}", command);
}
String[] args = GenericUtils.split(command, ' ');
int numArgs = GenericUtils.length(args);
for (int i = 1; i < numArgs; i++) {
String argVal = args[i];
if (argVal.charAt(0) == '-') {
for (int j = 1; j < argVal.length(); j++) {
char option = argVal.charAt(j);
switch (option) {
case 'f':
optF = true;
break;
case 'p':
optP = true;
break;
case 'r':
optR = true;
break;
case 't':
optT = true;
break;
case 'd':
optD = true;
break;
default: // ignored
if (debugEnabled) {
log.debug("Unknown flag ('{}') in command={}", option, command);
}
}
}
} else {
String prevArg = args[i - 1];
path = command.substring(command.indexOf(prevArg) + prevArg.length() + 1);
int pathLen = path.length();
char startDelim = path.charAt(0);
char endDelim = (pathLen > 2) ? path.charAt(pathLen - 1) : '\0';
// remove quotes
if ((pathLen > 2) && (startDelim == endDelim) && ((startDelim == '\'') || (startDelim == '"'))) {
path = path.substring(1, pathLen - 1);
}
break;
}
}
if ((!optF) && (!optT)) {
error = new IOException("Either -f or -t option should be set for " + command);
}
}