Class ChannelSftp

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ChannelSftp
    extends ChannelSession
    • Constructor Detail

      • ChannelSftp

        public ChannelSftp()
    • Method Detail

      • setBulkRequests

        public void setBulkRequests​(int bulk_requests)
                             throws JSchException
        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.
      • quit

        public void quit()
      • exit

        public void exit()
      • put

        public void put​(java.lang.String src,
                        java.lang.String dst,
                        SftpProgressMonitor monitor,
                        int mode)
                 throws SftpException
        Sends data from src file to dst file. The mode should be OVERWRITE, RESUME or APPEND.
        Parameters:
        src - source file
        dst - destination file
        monitor - progress monitor
        mode - how data should be added to dst
        Throws:
        SftpException
      • put

        public void put​(java.io.InputStream src,
                        java.lang.String dst,
                        SftpProgressMonitor monitor,
                        int mode)
                 throws SftpException
        Sends data from the input stream src to dst file. The mode should be OVERWRITE, RESUME or APPEND.
        Parameters:
        src - input stream
        dst - destination file
        monitor - progress monitor
        mode - how data should be added to dst
        Throws:
        SftpException
      • put

        public java.io.OutputStream put​(java.lang.String dst,
                                        SftpProgressMonitor monitor,
                                        int mode,
                                        long offset)
                                 throws SftpException
        Sends data from the output stream to dst file. The mode should be OVERWRITE, RESUME or APPEND.
        Parameters:
        dst - destination file
        monitor - progress monitor
        mode - how data should be added to dst
        offset - data will be added at offset
        Returns:
        output stream, which accepts data to be transferred.
        Throws:
        SftpException
      • get

        public java.io.InputStream get​(java.lang.String src,
                                       int mode)
                                throws SftpException
        Deprecated.
        This method will be deleted in the future.
        Throws:
        SftpException
      • ls

        public void ls​(java.lang.String path,
                       ChannelSftp.LsEntrySelector selector)
                throws SftpException
        List files specified by the remote path. Each files and directories will be passed to LsEntrySelector#select(LsEntry) method, and if that method returns LsEntrySelector#BREAK, the operation will be canceled immediately.
        Throws:
        SftpException
        Since:
        0.1.47
        See Also:
        ChannelSftp.LsEntrySelector
      • symlink

        public void symlink​(java.lang.String oldpath,
                            java.lang.String newpath)
                     throws SftpException
        Throws:
        SftpException
      • hardlink

        public void hardlink​(java.lang.String oldpath,
                             java.lang.String newpath)
                      throws SftpException
        Throws:
        SftpException
      • isRemoteDir

        private boolean isRemoteDir​(java.lang.String path)
      • _realpath

        private byte[] _realpath​(java.lang.String path)
                          throws SftpException,
                                 java.io.IOException,
                                 java.lang.Exception
        Throws:
        SftpException
        java.io.IOException
        java.lang.Exception
      • lpwd

        public java.lang.String lpwd()
      • version

        public java.lang.String version()
      • setCwd

        private void setCwd​(java.lang.String cwd)
      • read

        private void read​(byte[] buf,
                          int s,
                          int l)
                   throws java.io.IOException,
                          SftpException
        Throws:
        java.io.IOException
        SftpException
      • _sendCLOSE

        private boolean _sendCLOSE​(byte[] handle,
                                   ChannelSftp.Header header)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendINIT

        private void sendINIT()
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendREALPATH

        private void sendREALPATH​(byte[] path)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendSTAT

        private void sendSTAT​(byte[] path)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendSTATVFS

        private void sendSTATVFS​(byte[] path)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendLSTAT

        private void sendLSTAT​(byte[] path)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendFSTAT

        private void sendFSTAT​(byte[] handle)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendSETSTAT

        private void sendSETSTAT​(byte[] path,
                                 SftpATTRS attr)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendREMOVE

        private void sendREMOVE​(byte[] path)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendMKDIR

        private void sendMKDIR​(byte[] path,
                               SftpATTRS attr)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendRMDIR

        private void sendRMDIR​(byte[] path)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendSYMLINK

        private void sendSYMLINK​(byte[] p1,
                                 byte[] p2)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendHARDLINK

        private void sendHARDLINK​(byte[] p1,
                                  byte[] p2)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendREADLINK

        private void sendREADLINK​(byte[] path)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendOPENDIR

        private void sendOPENDIR​(byte[] path)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendREADDIR

        private void sendREADDIR​(byte[] path)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendRENAME

        private void sendRENAME​(byte[] p1,
                                byte[] p2)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendCLOSE

        private void sendCLOSE​(byte[] path)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendOPENR

        private void sendOPENR​(byte[] path)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendOPENW

        private void sendOPENW​(byte[] path)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendOPENA

        private void sendOPENA​(byte[] path)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendOPEN

        private void sendOPEN​(byte[] path,
                              int mode)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendPacketPath

        private void sendPacketPath​(byte fxp,
                                    byte[] path)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendPacketPath

        private void sendPacketPath​(byte fxp,
                                    byte[] path,
                                    java.lang.String extension)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendPacketPath

        private void sendPacketPath​(byte fxp,
                                    byte[] p1,
                                    byte[] p2)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendPacketPath

        private void sendPacketPath​(byte fxp,
                                    byte[] p1,
                                    byte[] p2,
                                    java.lang.String extension)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendWRITE

        private int sendWRITE​(byte[] handle,
                              long offset,
                              byte[] data,
                              int start,
                              int length)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendREAD

        private void sendREAD​(byte[] handle,
                              long offset,
                              int length)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendREAD

        private void sendREAD​(byte[] handle,
                              long offset,
                              int length,
                              ChannelSftp.RequestQueue rrq)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • putHEAD

        private void putHEAD​(Buffer buf,
                             byte type,
                             int length)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • putHEAD

        private void putHEAD​(byte type,
                             int length)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • glob_remote

        private java.util.Vector glob_remote​(java.lang.String _path)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isPattern

        private boolean isPattern​(byte[] path)
      • glob_local

        private java.util.Vector glob_local​(java.lang.String _path)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isLocalAbsolutePath

        private static boolean isLocalAbsolutePath​(java.lang.String path)
      • isPattern

        private boolean isPattern​(java.lang.String path,
                                  byte[][] utf8)
      • isPattern

        private boolean isPattern​(java.lang.String path)
      • fill

        private void fill​(Buffer buf,
                          int len)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • fill

        private int fill​(byte[] buf,
                         int s,
                         int len)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • skip

        private void skip​(long foo)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • remoteAbsolutePath

        private java.lang.String remoteAbsolutePath​(java.lang.String path)
                                             throws SftpException
        Throws:
        SftpException
      • localAbsolutePath

        private java.lang.String localAbsolutePath​(java.lang.String path)
      • isUnique

        private java.lang.String isUnique​(java.lang.String path)
                                   throws SftpException,
                                          java.lang.Exception
        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
        java.lang.Exception
      • getExtension

        public java.lang.String getExtension​(java.lang.String key)