Caclulate how much of the stream actually is needed

This commit is contained in:
Maschell 2019-04-30 12:04:49 +02:00
parent e461e78313
commit 79365a9fe6

View File

@ -110,12 +110,21 @@ public class FSTDataProviderNUSTitle implements FSTDataProvider, HasNUSTitle {
streamFilesize = curVal; streamFilesize = curVal;
} }
} else { } else {
streamOffset = (payloadOffset / 0x8000) * 0x8000; if (size != entry.getFileSize()) {
// We need the previous IV if we don't start at the first block. streamOffset = (payloadOffset / 0x8000) * 0x8000;
if (payloadOffset >= 0x8000 && payloadOffset % 0x8000 == 0) {
streamOffset -= 16; // We need the missing bytes of the previous blocks + the size we want to read.
streamFilesize = size;
long offsetInBlock = offset - streamOffset;
streamFilesize += offsetInBlock;
// We need the previous IV if we don't start at the first block.
if (payloadOffset >= 0x8000 && payloadOffset % 0x8000 == 0) {
streamOffset -= 16;
streamFilesize += 16;
}
} }
streamFilesize = c.getEncryptedFileSize();
} }
NUSDataProvider dataProvider = title.getDataProvider(); NUSDataProvider dataProvider = title.getDataProvider();