|
|
|
@ -226,11 +226,13 @@ var rDDecode = [0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32,
|
|
|
|
|
48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072,
|
|
|
|
|
4096, 6144, 8192, 12288, 16384, 24576, 32768, 49152, 65536, 98304,
|
|
|
|
|
131072, 196608, 262144, 327680, 393216, 458752, 524288, 589824,
|
|
|
|
|
655360, 720896, 786432, 851968, 917504, 983040];
|
|
|
|
|
655360, 720896, 786432, 851968, 917504, 983040
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var rDBits = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5,
|
|
|
|
|
5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
|
|
|
|
|
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16];
|
|
|
|
|
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var rLOW_DIST_REP_COUNT = 16;
|
|
|
|
|
|
|
|
|
@ -328,15 +330,13 @@ function RarReadTables(bstream) {
|
|
|
|
|
var ZeroCount = bstream.readBits(4);
|
|
|
|
|
if (ZeroCount == 0) {
|
|
|
|
|
BitLength[I] = 15;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
ZeroCount += 2;
|
|
|
|
|
while (ZeroCount-- > 0 && I < rBC)
|
|
|
|
|
BitLength[I++] = 0;
|
|
|
|
|
--I;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
BitLength[I] = Length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -381,24 +381,26 @@ function RarReadTables(bstream) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RarDecodeNumber(bstream, dec) {
|
|
|
|
|
var DecodeLen = dec.DecodeLen, DecodePos = dec.DecodePos, DecodeNum = dec.DecodeNum;
|
|
|
|
|
var DecodeLen = dec.DecodeLen,
|
|
|
|
|
DecodePos = dec.DecodePos,
|
|
|
|
|
DecodeNum = dec.DecodeNum;
|
|
|
|
|
var bitField = bstream.getBits() & 0xfffe;
|
|
|
|
|
//some sort of rolled out binary search
|
|
|
|
|
var bits = ((bitField < DecodeLen[8]) ?
|
|
|
|
|
((bitField < DecodeLen[4]) ?
|
|
|
|
|
((bitField < DecodeLen[2]) ?
|
|
|
|
|
((bitField < DecodeLen[1])?1:2)
|
|
|
|
|
:((bitField < DecodeLen[3])?3:4))
|
|
|
|
|
:(bitField < DecodeLen[6])?
|
|
|
|
|
((bitField < DecodeLen[5])?5:6)
|
|
|
|
|
:((bitField < DecodeLen[7])?7:8))
|
|
|
|
|
:((bitField < DecodeLen[12])?
|
|
|
|
|
((bitField < DecodeLen[1]) ? 1 : 2) :
|
|
|
|
|
((bitField < DecodeLen[3]) ? 3 : 4)) :
|
|
|
|
|
(bitField < DecodeLen[6]) ?
|
|
|
|
|
((bitField < DecodeLen[5]) ? 5 : 6) :
|
|
|
|
|
((bitField < DecodeLen[7]) ? 7 : 8)) :
|
|
|
|
|
((bitField < DecodeLen[12]) ?
|
|
|
|
|
((bitField < DecodeLen[10]) ?
|
|
|
|
|
((bitField < DecodeLen[9])?9:10)
|
|
|
|
|
:((bitField < DecodeLen[11])?11:12))
|
|
|
|
|
:(bitField < DecodeLen[14])?
|
|
|
|
|
((bitField < DecodeLen[13])?13:14)
|
|
|
|
|
:15));
|
|
|
|
|
((bitField < DecodeLen[9]) ? 9 : 10) :
|
|
|
|
|
((bitField < DecodeLen[11]) ? 11 : 12)) :
|
|
|
|
|
(bitField < DecodeLen[14]) ?
|
|
|
|
|
((bitField < DecodeLen[13]) ? 13 : 14) :
|
|
|
|
|
15));
|
|
|
|
|
bstream.readBits(bits);
|
|
|
|
|
var N = DecodePos[bits] + ((bitField - DecodeLen[bits - 1]) >>> (16 - bits));
|
|
|
|
|
|
|
|
|
@ -716,9 +718,9 @@ function RarAddVMCode(firstByte, vmCode) {
|
|
|
|
|
if (firstByte & 0x20) {
|
|
|
|
|
stackFilter.BlockLength = RarVM.readData(bstream);
|
|
|
|
|
} else {
|
|
|
|
|
stackFilter.BlockLength = filtPos < OldFilterLengths.length
|
|
|
|
|
? OldFilterLengths[filtPos]
|
|
|
|
|
: 0;
|
|
|
|
|
stackFilter.BlockLength = filtPos < OldFilterLengths.length ?
|
|
|
|
|
OldFilterLengths[filtPos] :
|
|
|
|
|
0;
|
|
|
|
|
}
|
|
|
|
|
stackFilter.NextWindow = (wBuffer.ptr != rBuffer.ptr) &&
|
|
|
|
|
(((wBuffer.ptr - rBuffer.ptr) & MAXWINMASK) <= blockStart);
|
|
|
|
@ -1138,8 +1140,7 @@ function RarWriteData(offset, numBytes) {
|
|
|
|
|
/**
|
|
|
|
|
* @param {VM_PreparedProgram} prg
|
|
|
|
|
*/
|
|
|
|
|
function RarExecuteCode(prg)
|
|
|
|
|
{
|
|
|
|
|
function RarExecuteCode(prg) {
|
|
|
|
|
if (prg.GlobalData.length > 0) {
|
|
|
|
|
var writtenFileSize = wBuffer.ptr;
|
|
|
|
|
prg.InitR[6] = writtenFileSize;
|
|
|
|
@ -1152,7 +1153,8 @@ function RarExecuteCode(prg)
|
|
|
|
|
function RarReadEndOfBlock(bstream) {
|
|
|
|
|
RarUpdateProgress();
|
|
|
|
|
|
|
|
|
|
var NewTable = false, NewFile = false;
|
|
|
|
|
var NewTable = false,
|
|
|
|
|
NewFile = false;
|
|
|
|
|
if (bstream.readBits(1)) {
|
|
|
|
|
NewTable = true;
|
|
|
|
|
} else {
|
|
|
|
@ -1242,8 +1244,7 @@ var RarLocalFile = function(bstream) {
|
|
|
|
|
if (this.header.headType != FILE_HEAD && this.header.headType != ENDARC_HEAD) {
|
|
|
|
|
this.isValid = false;
|
|
|
|
|
info("Error! RAR Volume did not include a FILE_HEAD header ");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
// read in the compressed data
|
|
|
|
|
this.fileData = null;
|
|
|
|
|
if (this.header.packSize > 0) {
|
|
|
|
@ -1296,8 +1297,7 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
var mhead = new RarVolumeHeader(bstream);
|
|
|
|
|
if (mhead.headType != MAIN_HEAD) {
|
|
|
|
|
info("Error! RAR did not include a MAIN_HEAD header");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
var localFiles = [],
|
|
|
|
|
localFile = null;
|
|
|
|
|
do {
|
|
|
|
@ -1325,7 +1325,9 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
return aname > bname ? 1 : -1;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
info(localFiles.map(function(a){return a.filename}).join(', '));
|
|
|
|
|
info(localFiles.map(function(a) {
|
|
|
|
|
return a.filename
|
|
|
|
|
}).join(', '));
|
|
|
|
|
for (var i = 0; i < localFiles.length; ++i) {
|
|
|
|
|
var localfile = localFiles[i];
|
|
|
|
|
|
|
|
|
@ -1344,8 +1346,7 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
|
|
|
|
|
postProgress();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
err("Invalid RAR file");
|
|
|
|
|
}
|
|
|
|
|
postMessage(new bitjs.archive.UnarchiveFinishEvent());
|
|
|
|
|