Class ChunkReader
java.lang.Object
ghidra.framework.main.logviewer.model.ChunkReader
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetFile()
Returns the file being read.long
Returns the number of bytes in the input file.long
getStartOfNextLine
(long startByte) Returns the start of the next line after the given byte.List
<byte[]> readBytes
(long startByte, long endByte) Reads all bytes from the given byte to the end byte.Reads one chunk from the end of the file.Reads the next chunk in the file past the last one specified in theChunkModel
.readNextChunkFrom
(long startByte) Reads a chunk of data from the given location in the file.Reads the chunk immediately before the first visible one.void
reload()
-
Constructor Details
-
ChunkReader
- Parameters:
file
-model
-- Throws:
IOException
-
-
Method Details
-
getFileSize
Returns the number of bytes in the input file.- Returns:
- number of bytes
- Throws:
IOException
-
getFile
Returns the file being read.- Returns:
-
reload
- Throws:
IOException
-
readLastChunk
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
Reads the chunk immediately before the first visible one.- Returns:
- the previous chunk, or an empty list
- Throws:
IOException
-
readNextChunkFrom
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
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
Reads the next chunk in the file past the last one specified in theChunkModel
.- Returns:
- the lines of text read
- Throws:
FileNotFoundException
IOException
-
getStartOfNextLine
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
-