Package com.jcraft.jsch
Class ChannelSftp
java.lang.Object
com.jcraft.jsch.Channel
com.jcraft.jsch.ChannelSession
com.jcraft.jsch.ChannelSftp
- All Implemented Interfaces:
Runnable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classclassstatic interfaceThis interface will be passed as an argument forlsmethod.private classNested classes/interfaces inherited from class com.jcraft.jsch.Channel
Channel.MyPipedInputStream, Channel.PassiveInputStream, Channel.PassiveOutputStream -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]static final intprivate Bufferprivate intprivate Stringprivate booleanprivate booleanprivate booleanprivate Hashtableprivate Stringprivate booleanprivate static final Stringprivate static final charprivate static booleanprivate Stringprivate booleanprivate InputStreamprivate Stringprivate static final intprivate static final intprivate static final intprivate Bufferprivate Packetstatic final intprivate Packetstatic final intprivate ChannelSftp.RequestQueueprivate intprivate intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final Stringprivate StringFields inherited from class com.jcraft.jsch.ChannelSession
agent_forwarding, env, pty, tcol, terminal_mode, thp, trow, ttype, twp, xforwadingFields inherited from class com.jcraft.jsch.Channel
close, connected, connectTimeout, eof_local, eof_remote, exitstatus, id, index, io, lmpsize, lwsize, lwsize_max, notifyme, open_confirmation, recipient, reply, rmpsize, rwsize, SSH_MSG_CHANNEL_OPEN_CONFIRMATION, SSH_MSG_CHANNEL_OPEN_FAILURE, SSH_MSG_CHANNEL_WINDOW_ADJUST, SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, SSH_OPEN_CONNECT_FAILED, SSH_OPEN_RESOURCE_SHORTAGE, SSH_OPEN_UNKNOWN_CHANNEL_TYPE, thread, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void_get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) private SftpATTRSvoid_put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) private byte[]private boolean_sendCLOSE(byte[] handle, ChannelSftp.Header header) private voidprivate SftpATTRS_stat(byte[] path) private SftpATTRSprivate SftpStatVFS_statVFS(byte[] path) private SftpStatVFSvoidprivate booleancheckStatus(int[] ackid, ChannelSftp.Header header) voidvoidvoidvoidvoidexit()private intfill(byte[] buf, int s, int len) private voidDeprecated.This method will be deleted in the future.get(String src, SftpProgressMonitor monitor) get(String src, SftpProgressMonitor monitor, int mode) Deprecated.This method will be deleted in the future.get(String src, SftpProgressMonitor monitor, long skip) voidget(String src, OutputStream dst) voidget(String src, OutputStream dst, SftpProgressMonitor monitor) voidget(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) voidvoidget(String src, String dst, SftpProgressMonitor monitor) voidget(String src, String dst, SftpProgressMonitor monitor, int mode) intThis method will return the value how many requests may be sent at any one time.private StringgetCwd()getExtension(String key) getHome()intprivate Vectorglob_local(String _path) private Vectorglob_remote(String _path) voidprivate ChannelSftp.Headerheader(Buffer buf, ChannelSftp.Header header) (package private) voidinit()private static booleanisLocalAbsolutePath(String path) private booleanisPattern(byte[] path) private booleanprivate booleanprivate booleanisRemoteDir(String path) private StringThis method will check if the given string can be expanded to the unique string.voidprivate StringlocalAbsolutePath(String path) lpwd()voidls(String path, ChannelSftp.LsEntrySelector selector) List files specified by the remotepath.voidvoidput(InputStream src, String dst) voidput(InputStream src, String dst, int mode) voidput(InputStream src, String dst, SftpProgressMonitor monitor) voidput(InputStream src, String dst, SftpProgressMonitor monitor, int mode) Sends data from the input streamsrctodstfile.put(String dst, SftpProgressMonitor monitor, int mode) put(String dst, SftpProgressMonitor monitor, int mode, long offset) Sends data from the output stream todstfile.voidvoidvoidput(String src, String dst, SftpProgressMonitor monitor) voidput(String src, String dst, SftpProgressMonitor monitor, int mode) Sends data fromsrcfile todstfile.private voidputHEAD(byte type, int length) private voidpwd()voidquit()private voidread(byte[] buf, int s, int l) private StringremoteAbsolutePath(String path) voidvoidvoidprivate voidsendCLOSE(byte[] path) private voidsendFSTAT(byte[] handle) private voidsendHARDLINK(byte[] p1, byte[] p2) private voidsendINIT()private voidsendLSTAT(byte[] path) private voidprivate voidsendOPEN(byte[] path, int mode) private voidsendOPENA(byte[] path) private voidsendOPENDIR(byte[] path) private voidsendOPENR(byte[] path) private voidsendOPENW(byte[] path) private voidsendPacketPath(byte fxp, byte[] path) private voidsendPacketPath(byte fxp, byte[] p1, byte[] p2) private voidsendPacketPath(byte fxp, byte[] p1, byte[] p2, String extension) private voidsendPacketPath(byte fxp, byte[] path, String extension) private voidsendREAD(byte[] handle, long offset, int length) private voidsendREAD(byte[] handle, long offset, int length, ChannelSftp.RequestQueue rrq) private voidsendREADDIR(byte[] path) private voidsendREADLINK(byte[] path) private voidsendREALPATH(byte[] path) private voidsendREMOVE(byte[] path) private voidsendRENAME(byte[] p1, byte[] p2) private voidsendRMDIR(byte[] path) private voidsendSETSTAT(byte[] path, SftpATTRS attr) private voidsendSTAT(byte[] path) private voidsendSTATVFS(byte[] path) private voidsendSYMLINK(byte[] p1, byte[] p2) private intsendWRITE(byte[] handle, long offset, byte[] data, int start, int length) voidsetBulkRequests(int bulk_requests) Specify how many requests may be sent at any one time.private voidvoidsetFilenameEncoding(String encoding) voidvoidprivate voidskip(long foo) voidstart()voidprivate voidthrowStatusError(Buffer buf, int i) version()Methods inherited from class com.jcraft.jsch.ChannelSession
run, sendRequests, setAgentForwarding, setEnv, setEnv, setEnv, setPty, setPtySize, setPtyType, setPtyType, setTerminalMode, setXForwardingMethods inherited from class com.jcraft.jsch.Channel
addRemoteWindowSize, close, connect, connect, del, disconnect, eof, eof_remote, genChannelOpenPacket, getChannel, getChannel, getData, getExitStatus, getExtInputStream, getId, getInputStream, getOutputStream, getRecipient, getSession, isClosed, isConnected, isEOF, sendChannelOpen, sendOpenConfirmation, sendOpenFailure, sendSignal, setExitStatus, setExtOutputStream, setExtOutputStream, setInputStream, setInputStream, setLocalPacketSize, setLocalWindowSize, setLocalWindowSizeMax, setOutputStream, setOutputStream, setRecipient, setRemotePacketSize, setRemoteWindowSize, setSession, write, write, write_ext
-
Field Details
-
LOCAL_MAXIMUM_PACKET_SIZE
private static final int LOCAL_MAXIMUM_PACKET_SIZE- See Also:
-
LOCAL_WINDOW_SIZE_MAX
private static final int LOCAL_WINDOW_SIZE_MAX- See Also:
-
SSH_FXP_INIT
private static final byte SSH_FXP_INIT- See Also:
-
SSH_FXP_VERSION
private static final byte SSH_FXP_VERSION- See Also:
-
SSH_FXP_OPEN
private static final byte SSH_FXP_OPEN- See Also:
-
SSH_FXP_CLOSE
private static final byte SSH_FXP_CLOSE- See Also:
-
SSH_FXP_READ
private static final byte SSH_FXP_READ- See Also:
-
SSH_FXP_WRITE
private static final byte SSH_FXP_WRITE- See Also:
-
SSH_FXP_LSTAT
private static final byte SSH_FXP_LSTAT- See Also:
-
SSH_FXP_FSTAT
private static final byte SSH_FXP_FSTAT- See Also:
-
SSH_FXP_SETSTAT
private static final byte SSH_FXP_SETSTAT- See Also:
-
SSH_FXP_FSETSTAT
private static final byte SSH_FXP_FSETSTAT- See Also:
-
SSH_FXP_OPENDIR
private static final byte SSH_FXP_OPENDIR- See Also:
-
SSH_FXP_READDIR
private static final byte SSH_FXP_READDIR- See Also:
-
SSH_FXP_REMOVE
private static final byte SSH_FXP_REMOVE- See Also:
-
SSH_FXP_MKDIR
private static final byte SSH_FXP_MKDIR- See Also:
-
SSH_FXP_RMDIR
private static final byte SSH_FXP_RMDIR- See Also:
-
SSH_FXP_REALPATH
private static final byte SSH_FXP_REALPATH- See Also:
-
SSH_FXP_STAT
private static final byte SSH_FXP_STAT- See Also:
-
SSH_FXP_RENAME
private static final byte SSH_FXP_RENAME- See Also:
-
SSH_FXP_READLINK
private static final byte SSH_FXP_READLINK- See Also:
-
SSH_FXP_SYMLINK
private static final byte SSH_FXP_SYMLINK- See Also:
-
SSH_FXP_STATUS
private static final byte SSH_FXP_STATUS- See Also:
-
SSH_FXP_HANDLE
private static final byte SSH_FXP_HANDLE- See Also:
-
SSH_FXP_DATA
private static final byte SSH_FXP_DATA- See Also:
-
SSH_FXP_NAME
private static final byte SSH_FXP_NAME- See Also:
-
SSH_FXP_ATTRS
private static final byte SSH_FXP_ATTRS- See Also:
-
SSH_FXP_EXTENDED
private static final byte SSH_FXP_EXTENDED- See Also:
-
SSH_FXP_EXTENDED_REPLY
private static final byte SSH_FXP_EXTENDED_REPLY- See Also:
-
SSH_FXF_READ
private static final int SSH_FXF_READ- See Also:
-
SSH_FXF_WRITE
private static final int SSH_FXF_WRITE- See Also:
-
SSH_FXF_APPEND
private static final int SSH_FXF_APPEND- See Also:
-
SSH_FXF_CREAT
private static final int SSH_FXF_CREAT- See Also:
-
SSH_FXF_TRUNC
private static final int SSH_FXF_TRUNC- See Also:
-
SSH_FXF_EXCL
private static final int SSH_FXF_EXCL- See Also:
-
SSH_FILEXFER_ATTR_SIZE
private static final int SSH_FILEXFER_ATTR_SIZE- See Also:
-
SSH_FILEXFER_ATTR_UIDGID
private static final int SSH_FILEXFER_ATTR_UIDGID- See Also:
-
SSH_FILEXFER_ATTR_PERMISSIONS
private static final int SSH_FILEXFER_ATTR_PERMISSIONS- See Also:
-
SSH_FILEXFER_ATTR_ACMODTIME
private static final int SSH_FILEXFER_ATTR_ACMODTIME- See Also:
-
SSH_FILEXFER_ATTR_EXTENDED
private static final int SSH_FILEXFER_ATTR_EXTENDED- See Also:
-
SSH_FX_OK
public static final int SSH_FX_OK- See Also:
-
SSH_FX_EOF
public static final int SSH_FX_EOF- See Also:
-
SSH_FX_NO_SUCH_FILE
public static final int SSH_FX_NO_SUCH_FILE- See Also:
-
SSH_FX_PERMISSION_DENIED
public static final int SSH_FX_PERMISSION_DENIED- See Also:
-
SSH_FX_FAILURE
public static final int SSH_FX_FAILURE- See Also:
-
SSH_FX_BAD_MESSAGE
public static final int SSH_FX_BAD_MESSAGE- See Also:
-
SSH_FX_NO_CONNECTION
public static final int SSH_FX_NO_CONNECTION- See Also:
-
SSH_FX_CONNECTION_LOST
public static final int SSH_FX_CONNECTION_LOST- See Also:
-
SSH_FX_OP_UNSUPPORTED
public static final int SSH_FX_OP_UNSUPPORTED- See Also:
-
MAX_MSG_LENGTH
private static final int MAX_MSG_LENGTH- See Also:
-
OVERWRITE
public static final int OVERWRITE- See Also:
-
RESUME
public static final int RESUME- See Also:
-
APPEND
public static final int APPEND- See Also:
-
interactive
private boolean interactive -
seq
private int seq -
ackid
private int[] ackid -
buf
-
packet
-
obuf
-
opacket
-
client_version
private int client_version -
server_version
private int server_version -
version
-
extensions
-
io_in
-
extension_posix_rename
private boolean extension_posix_rename -
extension_statvfs
private boolean extension_statvfs -
extension_hardlink
private boolean extension_hardlink -
file_separator
-
file_separatorc
private static final char file_separatorc -
fs_is_bs
private static boolean fs_is_bs -
cwd
-
home
-
lcwd
-
UTF8
- See Also:
-
fEncoding
-
fEncoding_is_utf8
private boolean fEncoding_is_utf8 -
rq
-
-
Constructor Details
-
ChannelSftp
public ChannelSftp()
-
-
Method Details
-
setBulkRequests
Specify how many requests may be sent at any one time. Increasing this value may slightly improve file transfer speed but will increase memory usage. The default is 16 requests.- Parameters:
bulk_requests- how many requests may be outstanding at any one time.- Throws:
JSchException
-
getBulkRequests
public int getBulkRequests()This method will return the value how many requests may be sent at any one time.- Returns:
- how many requests may be sent at any one time.
-
init
void init() -
start
- Overrides:
startin classChannel- Throws:
JSchException
-
quit
public void quit() -
exit
public void exit() -
lcd
- Throws:
SftpException
-
cd
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
Sends data fromsrcfile todstfile. Themodeshould beOVERWRITE,RESUMEorAPPEND.- Parameters:
src- source filedst- destination filemonitor- progress monitormode- how data should be added to dst- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
public void put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException Sends data from the input streamsrctodstfile. Themodeshould beOVERWRITE,RESUMEorAPPEND.- Parameters:
src- input streamdst- destination filemonitor- progress monitormode- how data should be added to dst- Throws:
SftpException
-
_put
public void _put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException - Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
public OutputStream put(String dst, SftpProgressMonitor monitor, int mode, long offset) throws SftpException Sends data from the output stream todstfile. Themodeshould beOVERWRITE,RESUMEorAPPEND.- Parameters:
dst- destination filemonitor- progress monitormode- how data should be added to dstoffset- data will be added at offset- Returns:
- output stream, which accepts data to be transferred.
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
public void get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) throws SftpException - Throws:
SftpException
-
_get
private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) throws SftpException - Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
Deprecated.This method will be deleted in the future.- Throws:
SftpException
-
get
Deprecated.This method will be deleted in the future.- Throws:
SftpException
-
get
- Throws:
SftpException
-
ls
- Throws:
SftpException
-
ls
List files specified by the remotepath. Each files and directories will be passed toLsEntrySelector#select(LsEntry)method, and if that method returnsLsEntrySelector#BREAK, the operation will be canceled immediately.- Throws:
SftpException- Since:
- 0.1.47
- See Also:
-
readlink
- Throws:
SftpException
-
symlink
- Throws:
SftpException
-
hardlink
- Throws:
SftpException
-
rename
- Throws:
SftpException
-
rm
- Throws:
SftpException
-
isRemoteDir
-
chgrp
- Throws:
SftpException
-
chown
- Throws:
SftpException
-
chmod
- Throws:
SftpException
-
setMtime
- Throws:
SftpException
-
rmdir
- Throws:
SftpException
-
mkdir
- Throws:
SftpException
-
stat
- Throws:
SftpException
-
_stat
- Throws:
SftpException
-
_stat
- Throws:
SftpException
-
statVFS
- Throws:
SftpException
-
_statVFS
- Throws:
SftpException
-
_statVFS
- Throws:
SftpException
-
lstat
- Throws:
SftpException
-
_lstat
- Throws:
SftpException
-
_realpath
- Throws:
SftpExceptionIOExceptionException
-
setStat
- Throws:
SftpException
-
_setStat
- Throws:
SftpException
-
pwd
- Throws:
SftpException
-
lpwd
-
version
-
getHome
- Throws:
SftpException
-
getCwd
- Throws:
SftpException
-
setCwd
-
read
- Throws:
IOExceptionSftpException
-
checkStatus
private boolean checkStatus(int[] ackid, ChannelSftp.Header header) throws IOException, SftpException - Throws:
IOExceptionSftpException
-
_sendCLOSE
- Throws:
Exception
-
sendINIT
- Throws:
Exception
-
sendREALPATH
- Throws:
Exception
-
sendSTAT
- Throws:
Exception
-
sendSTATVFS
- Throws:
Exception
-
sendLSTAT
- Throws:
Exception
-
sendFSTAT
- Throws:
Exception
-
sendSETSTAT
- Throws:
Exception
-
sendREMOVE
- Throws:
Exception
-
sendMKDIR
- Throws:
Exception
-
sendRMDIR
- Throws:
Exception
-
sendSYMLINK
- Throws:
Exception
-
sendHARDLINK
- Throws:
Exception
-
sendREADLINK
- Throws:
Exception
-
sendOPENDIR
- Throws:
Exception
-
sendREADDIR
- Throws:
Exception
-
sendRENAME
- Throws:
Exception
-
sendCLOSE
- Throws:
Exception
-
sendOPENR
- Throws:
Exception
-
sendOPENW
- Throws:
Exception
-
sendOPENA
- Throws:
Exception
-
sendOPEN
- Throws:
Exception
-
sendPacketPath
- Throws:
Exception
-
sendPacketPath
- Throws:
Exception
-
sendPacketPath
- Throws:
Exception
-
sendPacketPath
- Throws:
Exception
-
sendWRITE
private int sendWRITE(byte[] handle, long offset, byte[] data, int start, int length) throws Exception - Throws:
Exception
-
sendREAD
- Throws:
Exception
-
sendREAD
private void sendREAD(byte[] handle, long offset, int length, ChannelSftp.RequestQueue rrq) throws Exception - Throws:
Exception
-
putHEAD
- Throws:
Exception
-
putHEAD
- Throws:
Exception
-
glob_remote
- Throws:
Exception
-
isPattern
private boolean isPattern(byte[] path) -
glob_local
- Throws:
Exception
-
throwStatusError
- Throws:
SftpException
-
isLocalAbsolutePath
-
disconnect
public void disconnect()- Overrides:
disconnectin classChannel
-
isPattern
-
isPattern
-
fill
- Throws:
IOException
-
fill
- Throws:
IOException
-
skip
- Throws:
IOException
-
header
- Throws:
IOException
-
remoteAbsolutePath
- Throws:
SftpException
-
localAbsolutePath
-
isUnique
This method will check if the given string can be expanded to the unique string. If it can be expanded to mutiple files, SftpException will be thrown.- Returns:
- the returned string is unquoted.
- Throws:
SftpExceptionException
-
getServerVersion
- Throws:
SftpException
-
setFilenameEncoding
- Throws:
SftpException
-
getExtension
-
realpath
- Throws:
SftpException
-