Class SftpFileSystem.Wrapper

    • Field Detail

      • count

        private final java.util.concurrent.atomic.AtomicInteger count
      • readSize

        private final int readSize
      • writeSize

        private final int writeSize
    • Constructor Detail

      • Wrapper

        private Wrapper​(SftpClient delegate,
                        int readSize,
                        int writeSize)
    • Method Detail

      • getVersion

        public int getVersion()
        Returns:
        The negotiated SFTP protocol version
      • getServerExtensions

        public java.util.NavigableMap<java.lang.String,​byte[]> getServerExtensions()
        Returns:
        An (unmodifiable) NavigableMap of the reported server extensions. where key=extension name (case insensitive)
      • getNameDecodingCharset

        public java.nio.charset.Charset getNameDecodingCharset()
        Returns:
        The (never null) Charset used to decode referenced files/folders names
        See Also:
        SftpModuleProperties.NAME_DECODING_CHARSET
      • setNameDecodingCharset

        public void setNameDecodingCharset​(java.nio.charset.Charset cs)
      • isClosing

        public boolean isClosing()
      • isOpen

        public boolean isOpen()
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • increment

        public void increment()
      • close

        public void close​(SftpClient.Handle handle)
                   throws java.io.IOException
        Description copied from interface: SftpClient
        Close the handle obtained from one of the open methods
        Specified by:
        close in interface SftpClient
        Overrides:
        close in class AbstractSftpClient
        Parameters:
        handle - The Handle to close
        Throws:
        java.io.IOException - If failed to execute
      • remove

        public void remove​(java.lang.String path)
                    throws java.io.IOException
        Specified by:
        remove in interface SftpClient
        Overrides:
        remove in class AbstractSftpClient
        Parameters:
        path - The remote path to remove
        Throws:
        java.io.IOException - If failed to execute
      • read

        public int read​(SftpClient.Handle handle,
                        long fileOffset,
                        byte[] dst,
                        int dstOffset,
                        int len)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(SftpClient.Handle handle,
                          long fileOffset,
                          byte[] src,
                          int srcOffset,
                          int len)
                   throws java.io.IOException
        Description copied from interface: SftpClient
        Write data to (open) file handle
        Specified by:
        write in interface SftpClient
        Overrides:
        write in class AbstractSftpClient
        Parameters:
        handle - The file SftpClient.Handle
        fileOffset - Zero-based offset to write in file
        src - Data buffer
        srcOffset - Offset of valid data in buffer
        len - Number of bytes to write
        Throws:
        java.io.IOException - If failed to write the data
      • mkdir

        public void mkdir​(java.lang.String path)
                   throws java.io.IOException
        Description copied from interface: SftpClient
        Create remote directory
        Specified by:
        mkdir in interface SftpClient
        Overrides:
        mkdir in class AbstractSftpClient
        Parameters:
        path - Remote directory path
        Throws:
        java.io.IOException - If failed to execute
      • rmdir

        public void rmdir​(java.lang.String path)
                   throws java.io.IOException
        Description copied from interface: SftpClient
        Remove remote directory
        Specified by:
        rmdir in interface SftpClient
        Overrides:
        rmdir in class AbstractSftpClient
        Parameters:
        path - Remote directory path
        Throws:
        java.io.IOException - If failed to execute
      • readDir

        public java.util.List<SftpClient.DirEntry> readDir​(SftpClient.Handle handle)
                                                    throws java.io.IOException
        Parameters:
        handle - Directory SftpClient.Handle to read from
        Returns:
        A List of entries - null to indicate no more entries Note: the list may be incomplete since the client and server have some internal imposed limit on the number of entries they can process. Therefore several calls to this method may be required (until null). In order to iterate over all the entries use SftpClient.readDir(String)
        Throws:
        java.io.IOException - If failed to access the remote site
      • canonicalPath

        public java.lang.String canonicalPath​(java.lang.String path)
                                       throws java.io.IOException
        Description copied from interface: SftpClient
        The effective "normalized" remote path
        Specified by:
        canonicalPath in interface SftpClient
        Overrides:
        canonicalPath in class AbstractSftpClient
        Parameters:
        path - The requested path - may be relative, and/or contain dots - e.g., ".", "..", "./foo", "../bar"
        Returns:
        The effective "normalized" remote path
        Throws:
        java.io.IOException - If failed to execute
      • readLink

        public java.lang.String readLink​(java.lang.String path)
                                  throws java.io.IOException
        Description copied from interface: SftpClient
        Retrieve target of a link
        Specified by:
        readLink in interface SftpClient
        Overrides:
        readLink in class AbstractSftpClient
        Parameters:
        path - Remote path that represents a link
        Returns:
        The link target
        Throws:
        java.io.IOException - If failed to execute
      • symLink

        public void symLink​(java.lang.String linkPath,
                            java.lang.String targetPath)
                     throws java.io.IOException
        Description copied from interface: SftpClient
        Create symbolic link
        Parameters:
        linkPath - The link location
        targetPath - The referenced target by the link
        Throws:
        java.io.IOException - If failed to execute
        See Also:
        SftpClient.link(String, String, boolean)
      • read

        public java.io.InputStream read​(java.lang.String path)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public java.io.InputStream read​(java.lang.String path,
                                        SftpClient.OpenMode... mode)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public java.io.InputStream read​(java.lang.String path,
                                        int bufferSize,
                                        java.util.Collection<SftpClient.OpenMode> mode)
                                 throws java.io.IOException
        Description copied from interface: SftpClient
        Read a remote file's data via an input stream
        Specified by:
        read in interface SftpClient
        Overrides:
        read in class AbstractSftpClient
        Parameters:
        path - The remote file path
        bufferSize - The internal read buffer size
        mode - The remote file SftpClient.OpenModes
        Returns:
        An InputStream for reading the remote file data
        Throws:
        java.io.IOException - If failed to execute
      • write

        public java.io.OutputStream write​(java.lang.String path)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public java.io.OutputStream write​(java.lang.String path,
                                          SftpClient.OpenMode... mode)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public java.io.OutputStream write​(java.lang.String path,
                                          int bufferSize,
                                          java.util.Collection<SftpClient.OpenMode> mode)
                                   throws java.io.IOException
        Description copied from interface: SftpClient
        Write to a remote file via an output stream
        Specified by:
        write in interface SftpClient
        Overrides:
        write in class AbstractSftpClient
        Parameters:
        path - The remote file path
        bufferSize - The internal write buffer size
        mode - The remote file SftpClient.OpenModes
        Returns:
        An OutputStream for writing the data
        Throws:
        java.io.IOException - If failed to execute
      • link

        public void link​(java.lang.String linkPath,
                         java.lang.String targetPath,
                         boolean symbolic)
                  throws java.io.IOException
        Description copied from interface: SftpClient
        Create a link
        Specified by:
        link in interface SftpClient
        Overrides:
        link in class AbstractSftpClient
        Parameters:
        linkPath - The link location
        targetPath - The referenced target by the link
        symbolic - If true then make this a symbolic link, otherwise a hard one
        Throws:
        java.io.IOException - If failed to execute
      • send

        public int send​(int cmd,
                        Buffer buffer)
                 throws java.io.IOException
        Parameters:
        cmd - Command to send - Note: only lower 8-bits are used
        buffer - The Buffer containing the command data
        Returns:
        The assigned request id
        Throws:
        java.io.IOException - if failed to send command
      • receive

        public Buffer receive​(int id)
                       throws java.io.IOException
        Parameters:
        id - The expected request id
        Returns:
        The received response Buffer containing the request id
        Throws:
        java.io.IOException - If connection closed or interrupted
      • receive

        public Buffer receive​(int id,
                              long timeout)
                       throws java.io.IOException
        Parameters:
        id - The expected request id
        timeout - The amount of time to wait for the response
        Returns:
        The received response Buffer containing the request id
        Throws:
        java.io.IOException - If connection closed or interrupted
      • receive

        public Buffer receive​(int id,
                              java.time.Duration timeout)
                       throws java.io.IOException
        Parameters:
        id - The expected request id
        timeout - The amount of time to wait for the response
        Returns:
        The received response Buffer containing the request id
        Throws:
        java.io.IOException - If connection closed or interrupted