mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
string stream extract - simplify file reads
This commit is contained in:
parent
f78dfc09df
commit
8a007e8fe1
@ -106,23 +106,24 @@ public class AbstractFileStringIntStream extends InputStream {
|
|||||||
try {
|
try {
|
||||||
//convert more strings, store in buffer
|
//convert more strings, store in buffer
|
||||||
long toRead = 0;
|
long toRead = 0;
|
||||||
int shiftSize = 0;
|
//int shiftSize = 0;
|
||||||
if (lastExtractResult != null && lastExtractResult.getTextLength() != 0
|
|
||||||
&& (shiftSize = FILE_BUF_SIZE - lastExtractResult.getFirstUnprocessedOff()) > 0) {
|
//if (lastExtractResult != null && lastExtractResult.getTextLength() != 0
|
||||||
//a string previously extracted
|
// && (shiftSize = FILE_BUF_SIZE - lastExtractResult.getFirstUnprocessedOff()) > 0) {
|
||||||
//shift the fileReadBuff past last bytes extracted
|
////a string previously extracted
|
||||||
//read only what's needed to fill the buffer
|
////shift the fileReadBuff past last bytes extracted
|
||||||
//to avoid losing chars and breaking or corrupting potential strings - preserve byte stream continuity
|
////read only what's needed to fill the buffer
|
||||||
byte[] temp = new byte[shiftSize];
|
////to avoid loosing chars and breaking or corrupting potential strings - preserve byte stream continuity
|
||||||
System.arraycopy(fileReadBuff, lastExtractResult.getFirstUnprocessedOff(),
|
//byte[] temp = new byte[shiftSize];
|
||||||
temp, 0, shiftSize);
|
//System.arraycopy(fileReadBuff, lastExtractResult.getFirstUnprocessedOff(),
|
||||||
System.arraycopy(temp, 0, fileReadBuff, 0, shiftSize);
|
// temp, 0, shiftSize);
|
||||||
toRead = Math.min(lastExtractResult.getFirstUnprocessedOff(), fileSize - fileReadOffset);
|
//System.arraycopy(temp, 0, fileReadBuff, 0, shiftSize);
|
||||||
lastExtractResult = null;
|
//toRead = Math.min(lastExtractResult.getFirstUnprocessedOff(), fileSize - fileReadOffset);
|
||||||
} else {
|
//lastExtractResult = null;
|
||||||
|
//} else {
|
||||||
//fill up entire fileReadBuff fresh
|
//fill up entire fileReadBuff fresh
|
||||||
toRead = Math.min(FILE_BUF_SIZE, fileSize - fileReadOffset);
|
toRead = Math.min(FILE_BUF_SIZE, fileSize - fileReadOffset);
|
||||||
}
|
//}
|
||||||
int read = content.read(fileReadBuff, fileReadOffset, toRead);
|
int read = content.read(fileReadBuff, fileReadOffset, toRead);
|
||||||
if (read == -1 || read == 0) {
|
if (read == -1 || read == 0) {
|
||||||
fileEOF = true;
|
fileEOF = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user