// logger.info("\n--------reading header--------");
size = rof.readFully(baseBlockBuffer, BaseBlock.BaseBlockSize);
if (size == 0) {
break;
}
BaseBlock block = new BaseBlock(baseBlockBuffer);
block.setPositionInFile(position);
switch (block.getHeaderType()) {
case MarkHeader:
markHead = new MarkHeader(block);
if (!markHead.isSignature()) {
throw new RarException(
RarException.RarExceptionType.badRarArchive);
}
headers.add(markHead);
// markHead.print();
break;
case MainHeader:
int mainHeaderSize = 0;
toRead = block.hasEncryptVersion() ? MainHeader.mainHeaderSizeWithEnc
: MainHeader.mainHeaderSize;
byte[] mainbuff = new byte[toRead];
mainHeaderSize = rof.readFully(mainbuff, toRead);
MainHeader mainhead = new MainHeader(block, mainbuff);
headers.add(mainhead);
this.newMhd = mainhead;
if (newMhd.isEncrypted()) {
throw new RarException(
RarExceptionType.rarEncryptedException);
}
// mainhead.print();
break;
case SignHeader:
int signHeaderSize = 0;
toRead = SignHeader.signHeaderSize;
byte[] signBuff = new byte[toRead];
signHeaderSize = rof.readFully(signBuff, toRead);
SignHeader signHead = new SignHeader(block, signBuff);
headers.add(signHead);
// logger.info("HeaderType: SignHeader");
break;
case AvHeader:
int avHeaderSize = 0;
toRead = AVHeader.avHeaderSize;
byte[] avBuff = new byte[toRead];
avHeaderSize = rof.readFully(avBuff, toRead);
AVHeader avHead = new AVHeader(block, avBuff);
headers.add(avHead);
// logger.info("headertype: AVHeader");
break;
case CommHeader:
int commHeaderSize = 0;
toRead = CommentHeader.commentHeaderSize;
byte[] commBuff = new byte[toRead];
commHeaderSize = rof.readFully(commBuff, toRead);
CommentHeader commHead = new CommentHeader(block, commBuff);
headers.add(commHead);
// logger.info("method: "+commHead.getUnpMethod()+"; 0x"+
// Integer.toHexString(commHead.getUnpMethod()));
newpos = commHead.getPositionInFile()
+ commHead.getHeaderSize();
rof.setPosition(newpos);
break;
case EndArcHeader:
toRead = 0;
if (block.hasArchiveDataCRC()) {
toRead += EndArcHeader.endArcArchiveDataCrcSize;
}
if (block.hasVolumeNumber()) {
toRead += EndArcHeader.endArcVolumeNumberSize;
}
EndArcHeader endArcHead;
if (toRead > 0) {
int endArcHeaderSize = 0;