1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-03 17:49:16 +02:00

Track number of compressed bytes read in while unarchiving and reporting progress

This commit is contained in:
codedread 2018-01-26 00:12:58 -08:00
parent 8c630c170c
commit 23e3921072
4 changed files with 13 additions and 4 deletions

View file

@ -104,9 +104,11 @@ bitjs.archive.UnarchiveProgressEvent = class extends bitjs.archive.UnarchiveEven
* @param {number} currentBytesUnarchived * @param {number} currentBytesUnarchived
* @param {number} totalUncompressedBytesInArchive * @param {number} totalUncompressedBytesInArchive
* @param {number} totalFilesInArchive * @param {number} totalFilesInArchive
* @param {number} totalCompressedBytesRead
*/ */
constructor(currentFilename, currentFileNumber, currentBytesUnarchivedInFile, constructor(currentFilename, currentFileNumber, currentBytesUnarchivedInFile,
currentBytesUnarchived, totalUncompressedBytesInArchive, totalFilesInArchive) { currentBytesUnarchived, totalUncompressedBytesInArchive, totalFilesInArchive,
totalCompressedBytesRead) {
super(bitjs.archive.UnarchiveEvent.Type.PROGRESS); super(bitjs.archive.UnarchiveEvent.Type.PROGRESS);
this.currentFilename = currentFilename; this.currentFilename = currentFilename;
@ -115,6 +117,7 @@ bitjs.archive.UnarchiveProgressEvent = class extends bitjs.archive.UnarchiveEven
this.totalFilesInArchive = totalFilesInArchive; this.totalFilesInArchive = totalFilesInArchive;
this.currentBytesUnarchived = currentBytesUnarchived; this.currentBytesUnarchived = currentBytesUnarchived;
this.totalUncompressedBytesInArchive = totalUncompressedBytesInArchive; this.totalUncompressedBytesInArchive = totalUncompressedBytesInArchive;
this.totalCompressedBytesRead = totalCompressedBytesRead;
} }
} }

View file

@ -47,7 +47,9 @@ const postProgress = function() {
currentBytesUnarchivedInFile, currentBytesUnarchivedInFile,
currentBytesUnarchived, currentBytesUnarchived,
totalUncompressedBytesInArchive, totalUncompressedBytesInArchive,
totalFilesInArchive)); totalFilesInArchive,
parseInt(bitstream.getNumBitsRead() / 8, 10),
));
}; };
// shows a byte value as its hex representation // shows a byte value as its hex representation

View file

@ -48,7 +48,9 @@ const postProgress = function() {
currentBytesUnarchivedInFile, currentBytesUnarchivedInFile,
currentBytesUnarchived, currentBytesUnarchived,
totalUncompressedBytesInArchive, totalUncompressedBytesInArchive,
totalFilesInArchive)); totalFilesInArchive,
bytestream.getNumBytesRead(),
));
}; };
// Removes all characters from the first zero-byte in the string onwards. // Removes all characters from the first zero-byte in the string onwards.

View file

@ -52,7 +52,9 @@ const postProgress = function() {
currentBytesUnarchivedInFile, currentBytesUnarchivedInFile,
currentBytesUnarchived, currentBytesUnarchived,
totalUncompressedBytesInArchive, totalUncompressedBytesInArchive,
totalFilesInArchive)); totalFilesInArchive,
bytestream.getNumBytesRead(),
));
}; };
const zLocalFileHeaderSignature = 0x04034b50; const zLocalFileHeaderSignature = 0x04034b50;