Interface SftpFileSystemAccessor


  • public interface SftpFileSystemAccessor
    • Field Detail

      • DEFAULT_UNIX_VIEW

        static final java.util.List<java.lang.String> DEFAULT_UNIX_VIEW
      • FILEATTRS_RESOLVERS

        static final java.util.NavigableMap<java.lang.String,​FileInfoExtractor<?>> FILEATTRS_RESOLVERS
        A case insensitive NavigableMap of FileInfoExtractors to be used to complete attributes that are deemed important enough to warrant an extra effort if not accessible via the file system attributes views
      • PROP_AUTO_SYNC_FILE_ON_CLOSE

        static final java.lang.String PROP_AUTO_SYNC_FILE_ON_CLOSE
        Whether to invoke FileChannel.force(boolean) on files open for write when closing
        See Also:
        Constant Field Values
    • Method Detail

      • openFile

        default java.nio.channels.SeekableByteChannel openFile​(ServerSession session,
                                                               SftpEventListenerManager subsystem,
                                                               FileHandle fileHandle,
                                                               java.nio.file.Path file,
                                                               java.lang.String handle,
                                                               java.util.Set<? extends java.nio.file.OpenOption> options,
                                                               java.nio.file.attribute.FileAttribute<?>... attrs)
                                                        throws java.io.IOException
        Called whenever a new file is opened
        Parameters:
        session - The ServerSession through which the request was received
        subsystem - The SFTP subsystem instance that manages the session
        fileHandle - The FileHandle representing the created channel - may be null if not invoked within the context of such a handle (special cases)
        file - The requested local file Path
        handle - The assigned file handle through which the remote peer references this file. May be null/empty if the request is due to some internal functionality instead of due to peer requesting a handle to a file.
        options - The requested OpenOptions
        attrs - The requested FileAttributes
        Returns:
        The opened SeekableByteChannel
        Throws:
        java.io.IOException - If failed to open
      • tryLock

        default java.nio.channels.FileLock tryLock​(ServerSession session,
                                                   SftpEventListenerManager subsystem,
                                                   FileHandle fileHandle,
                                                   java.nio.file.Path file,
                                                   java.lang.String handle,
                                                   java.nio.channels.Channel channel,
                                                   long position,
                                                   long size,
                                                   boolean shared)
                                            throws java.io.IOException
        Called when locking a section of a file is requested
        Parameters:
        session - The ServerSession through which the request was received
        subsystem - The SFTP subsystem instance that manages the session
        fileHandle - The FileHandle representing the created channel
        file - The requested local file Path
        handle - The assigned file handle through which the remote peer references this file
        channel - The original Channel that was returned by openFile(ServerSession, SftpEventListenerManager, FileHandle, Path, String, Set, FileAttribute...)
        position - The position at which the locked region is to start - must be non-negative
        size - The size of the locked region; must be non-negative, and the sum position + size must be non-negative
        shared - true to request a shared lock, false to request an exclusive lock
        Returns:
        A lock object representing the newly-acquired lock, or null if the lock could not be acquired because another program holds an overlapping lock
        Throws:
        java.io.IOException - If failed to honor the request
        See Also:
        FileChannel.tryLock(long, long, boolean)
      • closeFile

        default void closeFile​(ServerSession session,
                               SftpEventListenerManager subsystem,
                               FileHandle fileHandle,
                               java.nio.file.Path file,
                               java.lang.String handle,
                               java.nio.channels.Channel channel,
                               java.util.Set<? extends java.nio.file.OpenOption> options)
                        throws java.io.IOException
        Called to inform the accessor that it should close the file
        Parameters:
        session - The ServerSession through which the request was received
        subsystem - The SFTP subsystem instance that manages the session
        fileHandle - The FileHandle representing the created channel - may be null if not invoked within the context of such a handle (special cases)
        file - The requested local file Path
        handle - The assigned file handle through which the remote peer references this file
        channel - The original Channel that was returned by openFile(ServerSession, SftpEventListenerManager, FileHandle, Path, String, Set, FileAttribute...)
        options - The original options used to open the channel
        Throws:
        java.io.IOException - If failed to execute the request
      • openDirectory

        default java.nio.file.DirectoryStream<java.nio.file.Path> openDirectory​(ServerSession session,
                                                                                SftpEventListenerManager subsystem,
                                                                                DirectoryHandle dirHandle,
                                                                                java.nio.file.Path dir,
                                                                                java.lang.String handle)
                                                                         throws java.io.IOException
        Called when a new directory stream is requested
        Parameters:
        session - The ServerSession through which the request was received
        subsystem - The SFTP subsystem instance that manages the session
        dirHandle - The DirectoryHandle representing the stream
        dir - The requested local directory
        handle - The assigned directory handle through which the remote peer references this directory
        Returns:
        The opened DirectoryStream
        Throws:
        java.io.IOException - If failed to open
      • closeDirectory

        default void closeDirectory​(ServerSession session,
                                    SftpEventListenerManager subsystem,
                                    DirectoryHandle dirHandle,
                                    java.nio.file.Path dir,
                                    java.lang.String handle,
                                    java.nio.file.DirectoryStream<java.nio.file.Path> ds)
                             throws java.io.IOException
        Called when a directory stream is no longer required
        Parameters:
        session - The ServerSession through which the request was received
        subsystem - The SFTP subsystem instance that manages the session
        dirHandle - The DirectoryHandle representing the stream - may be null if not invoked within the context of such a handle (special cases)
        dir - The requested local directory
        handle - The assigned directory handle through which the remote peer references this directory
        ds - The disposed DirectoryStream
        Throws:
        java.io.IOException - If failed to open