Class SftpFileObject

    • Field Detail

      • attrs

        private com.jcraft.jsch.SftpATTRS attrs
      • relPath

        private final java.lang.String relPath
    • Method Detail

      • doCreateFolder

        protected void doCreateFolder()
                               throws java.lang.Exception
        Creates this file as a folder.
        Overrides:
        doCreateFolder in class AbstractFileObject<SftpFileSystem>
        Throws:
        java.lang.Exception - if an error occurs.
      • doDetach

        protected void doDetach()
                         throws java.lang.Exception
        Description copied from class: AbstractFileObject
        Detaches this file object from its file resource.

        Called when this file is closed. Note that the file object may be reused later, so should be able to be reattached.

        This implementation does nothing.

        Overrides:
        doDetach in class AbstractFileObject<SftpFileSystem>
        Throws:
        java.lang.Exception - if an error occurs.
        Since:
        2.0
      • doGetContentSize

        protected long doGetContentSize()
                                 throws java.lang.Exception
        Returns the size of the file content (in bytes).
        Specified by:
        doGetContentSize in class AbstractFileObject<SftpFileSystem>
        Returns:
        The size of the file in bytes.
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetInputStream

        protected java.io.InputStream doGetInputStream​(int bufferSize)
                                                throws java.lang.Exception
        Creates an input stream to read the file content from.
        Overrides:
        doGetInputStream in class AbstractFileObject<SftpFileSystem>
        Parameters:
        bufferSize - Buffer size hint.
        Returns:
        An InputStream to read the file content.
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetOutputStream

        protected java.io.OutputStream doGetOutputStream​(boolean bAppend)
                                                  throws java.lang.Exception
        Creates an output stream to write the file content to.
        Overrides:
        doGetOutputStream in class AbstractFileObject<SftpFileSystem>
        Parameters:
        bAppend - true if the file should be appended to, false if it should be overwritten.
        Returns:
        An OutputStream to write to the file.
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetType

        protected FileType doGetType()
                              throws java.lang.Exception
        Determines the type of this file, returns null if the file does not exist.
        Specified by:
        doGetType in class AbstractFileObject<SftpFileSystem>
        Returns:
        the type of the file.
        Throws:
        java.lang.Exception - if an error occurs.
      • doListChildren

        protected java.lang.String[] doListChildren()
                                             throws java.lang.Exception
        Lists the children of this file.
        Specified by:
        doListChildren in class AbstractFileObject<SftpFileSystem>
        Returns:
        a possible empty String array if the file is a directory or null or an exception if the file is not a directory or can't be read.
        Throws:
        java.lang.Exception - if an error occurs.
      • doRename

        protected void doRename​(FileObject newFile)
                         throws java.lang.Exception
        Renames the file.
        Overrides:
        doRename in class AbstractFileObject<SftpFileSystem>
        Parameters:
        newFile - A FileObject with the new file name.
        Throws:
        java.lang.Exception - if an error occurs.
      • doSetLastModifiedTime

        protected boolean doSetLastModifiedTime​(long modtime)
                                         throws java.lang.Exception
        Sets the last modified time of this file. Is only called if doGetType() does not return FileType.IMAGINARY.
        Overrides:
        doSetLastModifiedTime in class AbstractFileObject<SftpFileSystem>
        Parameters:
        modtime - is modification time in milliseconds. SFTP protocol can send times with nanosecond precision but at the moment jsch send them with second precision.
        Returns:
        true if the time was set.
        Throws:
        java.lang.Exception - Any Exception thrown is wrapped in FileSystemException.
      • flushStat

        private void flushStat()
                        throws java.io.IOException,
                               com.jcraft.jsch.SftpException
        Throws:
        java.io.IOException
        com.jcraft.jsch.SftpException
      • getInputStream

        java.io.InputStream getInputStream​(long filePointer)
                                    throws java.io.IOException
        Creates an input stream to read the file content from. The input stream is starting at the given position in the file.
        Throws:
        java.io.IOException
      • getPermissions

        protected PosixPermissions getPermissions​(boolean checkIds)
                                           throws java.lang.Exception
        Returns the POSIX type permissions of the file.
        Parameters:
        checkIds - true if user and group ID should be checked (needed for some access rights checks)
        Returns:
        A PosixPermission object
        Throws:
        java.lang.Exception - If an error occurs
        Since:
        2.1
      • onChange

        protected void onChange()
                         throws java.lang.Exception
        Called when the type or content of this file changes.
        Overrides:
        onChange in class AbstractFileObject<SftpFileSystem>
        Throws:
        java.lang.Exception - if an error occurs.
      • setStat

        private void setStat​(com.jcraft.jsch.SftpATTRS attrs)
        Sets attrs from listChildrenResolved
      • statSelf

        private void statSelf()
                       throws java.io.IOException
        Fetches file attributes from server.
        Throws:
        java.io.IOException - if an error occurs.