|
|
@ -113,12 +113,12 @@ var RarVolumeHeader = function(bstream) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
bstream.readBits(16);
|
|
|
|
bstream.readBits(16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// byte 6,7
|
|
|
|
// byte 6,7
|
|
|
|
this.headSize = bstream.readBits(16);
|
|
|
|
this.headSize = bstream.readBits(16);
|
|
|
|
info(" headSize=" + this.headSize);
|
|
|
|
info(" headSize=" + this.headSize);
|
|
|
|
switch (this.headType) {
|
|
|
|
switch (this.headType) {
|
|
|
|
case MAIN_HEAD:
|
|
|
|
case MAIN_HEAD:
|
|
|
|
this.highPosAv = bstream.readBits(16);
|
|
|
|
this.highPosAv = bstream.readBits(16);
|
|
|
|
this.posAv = bstream.readBits(32);
|
|
|
|
this.posAv = bstream.readBits(32);
|
|
|
@ -367,7 +367,6 @@ function RarDecodeNumber(bstream, dec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RarMakeDecodeTables(BitLength, offset, dec, size) {
|
|
|
|
function RarMakeDecodeTables(BitLength, offset, dec, size) {
|
|
|
|
var DecodeLen = dec.DecodeLen, DecodePos = dec.DecodePos, DecodeNum = dec.DecodeNum;
|
|
|
|
var DecodeLen = dec.DecodeLen, DecodePos = dec.DecodePos, DecodeNum = dec.DecodeNum;
|
|
|
|
var LenCount = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
|
|
|
|
var LenCount = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
|
|
|
@ -394,7 +393,6 @@ function RarMakeDecodeTables(BitLength, offset, dec, size) {
|
|
|
|
for (I = 0; I < size; ++I)
|
|
|
|
for (I = 0; I < size; ++I)
|
|
|
|
if (BitLength[I + offset] != 0)
|
|
|
|
if (BitLength[I + offset] != 0)
|
|
|
|
DecodeNum[ TmpPos[ BitLength[offset + I] & 0xF ]++] = I;
|
|
|
|
DecodeNum[ TmpPos[ BitLength[offset + I] & 0xF ]++] = I;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: implement
|
|
|
|
// TODO: implement
|
|
|
@ -473,7 +471,6 @@ function Unpack20(bstream, Solid) {
|
|
|
|
RarCopyString(2, Distance);
|
|
|
|
RarCopyString(2, Distance);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RarUpdateProgress()
|
|
|
|
RarUpdateProgress()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -620,7 +617,6 @@ function Unpack29(bstream, Solid) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (num == 256) {
|
|
|
|
if (num == 256) {
|
|
|
|
if (!RarReadEndOfBlock(bstream)) break;
|
|
|
|
if (!RarReadEndOfBlock(bstream)) break;
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (num == 257) {
|
|
|
|
if (num == 257) {
|
|
|
@ -662,7 +658,6 @@ function Unpack29(bstream, Solid) {
|
|
|
|
RarCopyString(2, Distance);
|
|
|
|
RarCopyString(2, Distance);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RarUpdateProgress()
|
|
|
|
RarUpdateProgress()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -671,7 +666,6 @@ function RarReadEndOfBlock(bstream) {
|
|
|
|
|
|
|
|
|
|
|
|
RarUpdateProgress()
|
|
|
|
RarUpdateProgress()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var NewTable = false, NewFile = false;
|
|
|
|
var NewTable = false, NewFile = false;
|
|
|
|
if (bstream.readBits(1)) {
|
|
|
|
if (bstream.readBits(1)) {
|
|
|
|
NewTable = true;
|
|
|
|
NewTable = true;
|
|
|
@ -728,14 +722,12 @@ function RarCopyString(length, distance) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//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++]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (length > distance) {
|
|
|
|
if (length > distance) {
|
|
|
|
while(length--) rBuffer.insertByte(rBuffer.data[destPtr++]);
|
|
|
|
while(length--) rBuffer.insertByte(rBuffer.data[destPtr++]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
rBuffer.insertBytes(rBuffer.data.subarray(destPtr, destPtr + length));
|
|
|
|
rBuffer.insertBytes(rBuffer.data.subarray(destPtr, destPtr + length));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var rOldBuffers = []
|
|
|
|
var rOldBuffers = []
|
|
|
@ -828,14 +820,14 @@ var unrar = function(arrayBuffer) {
|
|
|
|
if (header.crc == 0x6152 &&
|
|
|
|
if (header.crc == 0x6152 &&
|
|
|
|
header.headType == 0x72 &&
|
|
|
|
header.headType == 0x72 &&
|
|
|
|
header.flags.value == 0x1A21 &&
|
|
|
|
header.flags.value == 0x1A21 &&
|
|
|
|
header.headSize == 7) {
|
|
|
|
header.headSize == 7)
|
|
|
|
|
|
|
|
{
|
|
|
|
info("Found RAR signature");
|
|
|
|
info("Found RAR signature");
|
|
|
|
|
|
|
|
|
|
|
|
var mhead = new RarVolumeHeader(bstream);
|
|
|
|
var mhead = new RarVolumeHeader(bstream);
|
|
|
|
if (mhead.headType != MAIN_HEAD) {
|
|
|
|
if (mhead.headType != MAIN_HEAD) {
|
|
|
|
info("Error! RAR did not include a MAIN_HEAD header");
|
|
|
|
info("Error! RAR did not include a MAIN_HEAD header");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
var localFiles = [],
|
|
|
|
var localFiles = [],
|
|
|
|
localFile = null;
|
|
|
|
localFile = null;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|