mirror of
https://github.com/codedread/bitjs
synced 2025-10-04 01:59:15 +02:00
Fix unrar when the file was stored.
This commit is contained in:
parent
e10786a049
commit
d70c44727b
2 changed files with 10 additions and 4 deletions
4
io.js
4
io.js
|
@ -194,7 +194,7 @@ bitjs.io.BitStream.prototype.readBits = function(n) {
|
||||||
* bits in the current byte.
|
* bits in the current byte.
|
||||||
* @param {number} n The number of bytes to peek.
|
* @param {number} n The number of bytes to peek.
|
||||||
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
|
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
|
||||||
* @return {number} The peeked bytes, as an unsigned number.
|
* @return {Uint8Array} The subarray.
|
||||||
*/
|
*/
|
||||||
bitjs.io.BitStream.prototype.peekBytes = function(n, movePointers) {
|
bitjs.io.BitStream.prototype.peekBytes = function(n, movePointers) {
|
||||||
if (n <= 0 || typeof n != typeof 1) {
|
if (n <= 0 || typeof n != typeof 1) {
|
||||||
|
@ -223,7 +223,7 @@ bitjs.io.BitStream.prototype.peekBytes = function(n, movePointers) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} n The number of bytes to read.
|
* @param {number} n The number of bytes to read.
|
||||||
* @return {number} The read bytes, as a number.
|
* @return {Uint8Array} The subarray.
|
||||||
*/
|
*/
|
||||||
bitjs.io.BitStream.prototype.readBytes = function(n) {
|
bitjs.io.BitStream.prototype.readBytes = function(n) {
|
||||||
return this.peekBytes(n, true);
|
return this.peekBytes(n, true);
|
||||||
|
|
8
unrar.js
8
unrar.js
|
@ -724,7 +724,7 @@ function RarCopyString(length, distance) {
|
||||||
if(destPtr < 0){
|
if(destPtr < 0){
|
||||||
var l = rOldBuffers.length;
|
var l = rOldBuffers.length;
|
||||||
while(destPtr < 0){
|
while(destPtr < 0){
|
||||||
destPtr = rOldBuffers[--l].data.length + destPtr
|
destPtr = rOldBuffers[--l].data.length + destPtr;
|
||||||
}
|
}
|
||||||
//TODO: lets hope that it never needs to read beyond file boundaries
|
//TODO: lets hope that it never needs to read beyond file boundaries
|
||||||
while(length--) rBuffer.insertByte(rOldBuffers[l].data[destPtr++]);
|
while(length--) rBuffer.insertByte(rOldBuffers[l].data[destPtr++]);
|
||||||
|
@ -800,6 +800,12 @@ RarLocalFile.prototype.unrar = function() {
|
||||||
|
|
||||||
currentBytesUnarchivedInFile += this.fileData.length;
|
currentBytesUnarchivedInFile += this.fileData.length;
|
||||||
currentBytesUnarchived += this.fileData.length;
|
currentBytesUnarchived += this.fileData.length;
|
||||||
|
|
||||||
|
// Create a new buffer and copy it over.
|
||||||
|
var len = this.header.packSize;
|
||||||
|
var newBuffer = new bitjs.io.ByteBuffer(len);
|
||||||
|
newBuffer.insertBytes(this.fileData);
|
||||||
|
this.fileData = newBuffer.data;
|
||||||
} else {
|
} else {
|
||||||
this.isValid = true;
|
this.isValid = true;
|
||||||
this.fileData = unpack(this);
|
this.fileData = unpack(this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue