🐛 Don't read additional 12 bytes after each file
This commit is contained in:
parent
f64412ebfe
commit
2299d8ed6e
1 changed files with 5 additions and 3 deletions
|
@ -70,10 +70,13 @@ int main(int argc, char *argv[]) {
|
|||
getBytes(NULL, additionalLength, false);
|
||||
}
|
||||
|
||||
unsigned long remainingBytes = state.fileSize;
|
||||
|
||||
//If file is encrypted, skip 12-byte encryption header
|
||||
if (state.isEncrypted) {
|
||||
getBytes(compressedChunk, ENCRYPTION_HEADER_LENGTH, false);
|
||||
decrypt(compressedChunk, ENCRYPTION_HEADER_LENGTH);
|
||||
remainingBytes -= 12;
|
||||
}
|
||||
|
||||
//Initialize xdelta3
|
||||
|
@ -87,14 +90,13 @@ int main(int argc, char *argv[]) {
|
|||
inflateInit(compressedChunk, uncompressedChunk, BUFFER_SIZE);
|
||||
|
||||
//Read actual file
|
||||
unsigned long remainingBytes = state.fileSize;
|
||||
bool needToRead = true;
|
||||
bool hasReachedEnd = false;
|
||||
unsigned long chunkSize;
|
||||
unsigned long uncompressedPosition = 0UL;
|
||||
while (remainingBytes > 0 || !hasReachedEnd) {
|
||||
if (needToRead) {
|
||||
chunkSize = min(BUFFER_SIZE - uncompressedPosition, remainingBytes);
|
||||
if (needToRead && remainingBytes > 0) {
|
||||
chunkSize = min(BUFFER_SIZE, remainingBytes);
|
||||
getBytes(compressedChunk, chunkSize, chunkSize == remainingBytes);
|
||||
remainingBytes -= chunkSize;
|
||||
|
||||
|
|
Loading…
Reference in a new issue