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) class
class
static interface
This interface will be passed as an argument forls
method.private class
Nested classes/interfaces inherited from class com.jcraft.jsch.Channel
Channel.MyPipedInputStream, Channel.PassiveInputStream, Channel.PassiveOutputStream
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
static final int
private Buffer
private int
private String
private boolean
private boolean
private boolean
private Hashtable
private String
private boolean
private static final String
private static final char
private static boolean
private String
private boolean
private InputStream
private String
private static final int
private static final int
private static final int
private Buffer
private Packet
static final int
private Packet
static final int
private ChannelSftp.RequestQueue
private int
private int
private static final int
private static final int
private static final int
private static final int
private static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final String
private String
Fields inherited from class com.jcraft.jsch.ChannelSession
agent_forwarding, env, pty, tcol, terminal_mode, thp, trow, ttype, twp, xforwading
Fields 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 SftpATTRS
void
_put
(InputStream src, String dst, SftpProgressMonitor monitor, int mode) private byte[]
private boolean
_sendCLOSE
(byte[] handle, ChannelSftp.Header header) private void
private SftpATTRS
_stat
(byte[] path) private SftpATTRS
private SftpStatVFS
_statVFS
(byte[] path) private SftpStatVFS
void
private boolean
checkStatus
(int[] ackid, ChannelSftp.Header header) void
void
void
void
void
exit()
private int
fill
(byte[] buf, int s, int len) private void
Deprecated.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) void
get
(String src, OutputStream dst) void
get
(String src, OutputStream dst, SftpProgressMonitor monitor) void
get
(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) void
void
get
(String src, String dst, SftpProgressMonitor monitor) void
get
(String src, String dst, SftpProgressMonitor monitor, int mode) int
This method will return the value how many requests may be sent at any one time.private String
getCwd()
getExtension
(String key) getHome()
int
private Vector
glob_local
(String _path) private Vector
glob_remote
(String _path) void
private ChannelSftp.Header
header
(Buffer buf, ChannelSftp.Header header) (package private) void
init()
private static boolean
isLocalAbsolutePath
(String path) private boolean
isPattern
(byte[] path) private boolean
private boolean
private boolean
isRemoteDir
(String path) private String
This method will check if the given string can be expanded to the unique string.void
private String
localAbsolutePath
(String path) lpwd()
void
ls
(String path, ChannelSftp.LsEntrySelector selector) List files specified by the remotepath
.void
void
put
(InputStream src, String dst) void
put
(InputStream src, String dst, int mode) void
put
(InputStream src, String dst, SftpProgressMonitor monitor) void
put
(InputStream src, String dst, SftpProgressMonitor monitor, int mode) Sends data from the input streamsrc
todst
file.put
(String dst, SftpProgressMonitor monitor, int mode) put
(String dst, SftpProgressMonitor monitor, int mode, long offset) Sends data from the output stream todst
file.void
void
void
put
(String src, String dst, SftpProgressMonitor monitor) void
put
(String src, String dst, SftpProgressMonitor monitor, int mode) Sends data fromsrc
file todst
file.private void
putHEAD
(byte type, int length) private void
pwd()
void
quit()
private void
read
(byte[] buf, int s, int l) private String
remoteAbsolutePath
(String path) void
void
void
private void
sendCLOSE
(byte[] path) private void
sendFSTAT
(byte[] handle) private void
sendHARDLINK
(byte[] p1, byte[] p2) private void
sendINIT()
private void
sendLSTAT
(byte[] path) private void
private void
sendOPEN
(byte[] path, int mode) private void
sendOPENA
(byte[] path) private void
sendOPENDIR
(byte[] path) private void
sendOPENR
(byte[] path) private void
sendOPENW
(byte[] path) private void
sendPacketPath
(byte fxp, byte[] path) private void
sendPacketPath
(byte fxp, byte[] p1, byte[] p2) private void
sendPacketPath
(byte fxp, byte[] p1, byte[] p2, String extension) private void
sendPacketPath
(byte fxp, byte[] path, String extension) private void
sendREAD
(byte[] handle, long offset, int length) private void
sendREAD
(byte[] handle, long offset, int length, ChannelSftp.RequestQueue rrq) private void
sendREADDIR
(byte[] path) private void
sendREADLINK
(byte[] path) private void
sendREALPATH
(byte[] path) private void
sendREMOVE
(byte[] path) private void
sendRENAME
(byte[] p1, byte[] p2) private void
sendRMDIR
(byte[] path) private void
sendSETSTAT
(byte[] path, SftpATTRS attr) private void
sendSTAT
(byte[] path) private void
sendSTATVFS
(byte[] path) private void
sendSYMLINK
(byte[] p1, byte[] p2) private int
sendWRITE
(byte[] handle, long offset, byte[] data, int start, int length) void
setBulkRequests
(int bulk_requests) Specify how many requests may be sent at any one time.private void
void
setFilenameEncoding
(String encoding) void
void
private void
skip
(long foo) void
start()
void
private void
throwStatusError
(Buffer buf, int i) version()
Methods inherited from class com.jcraft.jsch.ChannelSession
run, sendRequests, setAgentForwarding, setEnv, setEnv, setEnv, setPty, setPtySize, setPtyType, setPtyType, setTerminalMode, setXForwarding
Methods 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:
start
in 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 fromsrc
file todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- 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 streamsrc
todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- 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 todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- 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:
SftpException
IOException
Exception
-
setStat
- Throws:
SftpException
-
_setStat
- Throws:
SftpException
-
pwd
- Throws:
SftpException
-
lpwd
-
version
-
getHome
- Throws:
SftpException
-
getCwd
- Throws:
SftpException
-
setCwd
-
read
- Throws:
IOException
SftpException
-
checkStatus
private boolean checkStatus(int[] ackid, ChannelSftp.Header header) throws IOException, SftpException - Throws:
IOException
SftpException
-
_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:
disconnect
in 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:
SftpException
Exception
-
getServerVersion
- Throws:
SftpException
-
setFilenameEncoding
- Throws:
SftpException
-
getExtension
-
realpath
- Throws:
SftpException
-