Class ChunkReader

java.lang.Object
ghidra.framework.main.logviewer.model.ChunkReader

public class ChunkReader extends Object
This class handles reading data from the input file, in the form of Chunk objects. Each chunk is stored in the ChunkModel and represents a single block of text that is displayed in the FVTable.
  • Constructor Details

  • Method Details

    • getFileSize

      public long getFileSize() throws IOException
      Returns the number of bytes in the input file.
      Returns:
      number of bytes
      Throws:
      IOException
    • getFile

      public File getFile()
      Returns the file being read.
      Returns:
    • reload

      public void reload() throws IOException
      Throws:
      IOException
    • readLastChunk

      public List<String> readLastChunk() throws IOException
      Reads one chunk from the end of the file. This is useful when scrolling to the bottom of the viewport.
      Returns:
      the last chunk, or an empty list
      Throws:
      IOException
    • readPreviousChunk

      public List<String> readPreviousChunk() throws IOException
      Reads the chunk immediately before the first visible one.
      Returns:
      the previous chunk, or an empty list
      Throws:
      IOException
    • readNextChunkFrom

      public List<String> readNextChunkFrom(long startByte) throws IOException
      Reads a chunk of data from the given location in the file. To ensure we're always reading full lines, take the given start position and move forward to the next full line before reading.
      Parameters:
      startByte - the position to start reading from
      Returns:
      the lines of text read
      Throws:
      IOException
    • readBytes

      public List<byte[]> readBytes(long startByte, long endByte) throws IOException
      Reads all bytes from the given byte to the end byte. If the amount of bytes to be read is greater than the size of an INT, we will have to read this in several chunks, hence the need to return a list of arrays, and not just a single byte array.
      Parameters:
      startByte -
      endByte -
      Returns:
      a map of all the bytes read in (index 0 is first chunk, 1 is next, etc...).
      Throws:
      IOException
    • readNextChunk

      public List<String> readNextChunk() throws FileNotFoundException, IOException
      Reads the next chunk in the file past the last one specified in the ChunkModel.
      Returns:
      the lines of text read
      Throws:
      FileNotFoundException
      IOException
    • getStartOfNextLine

      public long getStartOfNextLine(long startByte) throws IOException
      Returns the start of the next line after the given byte. To do this, simply read backwards from the given point until a newline or carriage return is found.
      Parameters:
      startByte -
      Returns:
      Throws:
      IOException