(CAF): support "RP" entries compression.

also support nested compression.
This commit is contained in:
morkt 2018-12-23 14:33:27 +04:00
parent 51c8bb5bfc
commit 4c90dd317c

View File

@ -86,23 +86,27 @@ namespace GameRes.Formats.Tail
const uint PrenSignature = 0x4E455250; // "PREN" const uint PrenSignature = 0x4E455250; // "PREN"
const uint Cfp0Signature = 0x30504643; // "CFP0" const uint Cfp0Signature = 0x30504643; // "CFP0"
const uint HpSignature = 0x00005048; // "HP" const uint HpSignature = 0x00005048; // "HP"
const uint RpSignature = 0x00005052; // "RP"
public override Stream OpenEntry (ArcFile arc, Entry entry) public override Stream OpenEntry (ArcFile arc, Entry entry)
{ {
var input = arc.File.CreateStream (entry.Offset, entry.Size, entry.Name); IBinaryStream input = arc.File.CreateStream (entry.Offset, entry.Size, entry.Name);
Func<IBinaryStream, byte[]> unpacker = null; Func<IBinaryStream, byte[]> unpacker = null;
switch (input.Signature) for (;;)
{ {
case PrenSignature: unpacker = UnpackPren; break; switch (input.Signature)
case Cfp0Signature: unpacker = UnpackCfp0; break; {
case HpSignature: unpacker = UnpackHp; break; case RpSignature:
case PrenSignature: unpacker = UnpackPren; break;
case Cfp0Signature: unpacker = UnpackCfp0; break;
case HpSignature: unpacker = UnpackHp; break;
default: return input; default: return input.AsStream;
} }
using (input) byte[] data;
{ using (input)
var data = unpacker (input); data = unpacker (input);
return new BinMemoryStream (data, entry.Name); input = new BinMemoryStream (data, entry.Name);
} }
} }