Class ObfuscatedFileByteProvider

  • All Implemented Interfaces:
    ByteProvider, MutableByteProvider, java.io.Closeable, java.lang.AutoCloseable

    public class ObfuscatedFileByteProvider
    extends FileByteProvider
    A ByteProvider that reads from an on-disk file, but obfuscates / de-obfuscates the contents of the file when reading / writing.
    • Constructor Detail

      • ObfuscatedFileByteProvider

        public ObfuscatedFileByteProvider​(java.io.File file,
                                          FSRL fsrl,
                                          java.nio.file.AccessMode accessMode)
                                   throws java.io.IOException
        Creates an instance of ObfuscatedFileByteProvider.
        Parameters:
        file - File to read from / write to
        fsrl - FSRL identity of this file
        accessMode - AccessMode.READ or AccessMode.WRITE
        Throws:
        java.io.IOException - if error
    • Method Detail

      • doReadBytes

        protected int doReadBytes​(long index,
                                  byte[] buffer)
                           throws java.io.IOException
        Description copied from class: FileByteProvider
        Reads bytes from the file.

        Protected by synchronized lock. (See FileByteProvider.getBufferFor(long)).

        Overrides:
        doReadBytes in class FileByteProvider
        Parameters:
        index - file position of where to read
        buffer - byte array that will receive bytes
        Returns:
        actual number of byte read
        Throws:
        java.io.IOException - if error
      • doWriteBytes

        protected void doWriteBytes​(long index,
                                    byte[] buffer,
                                    int offset,
                                    int length)
                             throws java.io.IOException
        Description copied from class: FileByteProvider
        Writes the specified bytes to the file.

        Protected by synchronized lock (See FileByteProvider.writeBytes(long, byte[], int, int))

        Overrides:
        doWriteBytes in class FileByteProvider
        Parameters:
        index - file position of where to write
        buffer - byte array containing bytes to write
        offset - offset inside of byte array to start
        length - number of bytes from buffer to write
        Throws:
        java.io.IOException - if error