mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 13:45:34 +08:00
(SCN): recongize zlib compression.
This commit is contained in:
parent
aadb48a7dc
commit
72452d664a
@ -80,25 +80,35 @@ namespace GameRes.Formats.Seraphim
|
|||||||
if (0 == entry.Size)
|
if (0 == entry.Size)
|
||||||
return Stream.Null;
|
return Stream.Null;
|
||||||
uint signature = arc.File.View.ReadUInt32 (entry.Offset);
|
uint signature = arc.File.View.ReadUInt32 (entry.Offset);
|
||||||
ArcViewStream input;
|
IBinaryStream input;
|
||||||
if (1 == signature && 0x78 == arc.File.View.ReadByte (entry.Offset+4))
|
if (1 == signature && 0x78 == arc.File.View.ReadByte (entry.Offset+4))
|
||||||
{
|
{
|
||||||
input = arc.File.CreateStream (entry.Offset+4, entry.Size-4);
|
input = arc.File.CreateStream (entry.Offset+4, entry.Size-4);
|
||||||
return new ZLibStream (input, CompressionMode.Decompress);
|
return new ZLibStream (input.AsStream, CompressionMode.Decompress);
|
||||||
}
|
}
|
||||||
input = arc.File.CreateStream (entry.Offset, entry.Size);
|
input = arc.File.CreateStream (entry.Offset, entry.Size);
|
||||||
if (signature < 4 || 0 != (signature & 0xFF000000))
|
if (signature < 4 || 0 != (signature & 0xFF000000))
|
||||||
return input;
|
{
|
||||||
|
if (0x78 == (signature & 0xFF))
|
||||||
|
{
|
||||||
|
var compr = new ZLibStream (input.AsStream, CompressionMode.Decompress);
|
||||||
|
input = new BinaryStream (compr, entry.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return input.AsStream;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = LzDecompress (input);
|
var data = LzDecompress (input);
|
||||||
input.Dispose();
|
|
||||||
return new BinMemoryStream (data, entry.Name);
|
return new BinMemoryStream (data, entry.Name);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
input.Position = 0;
|
return arc.File.CreateStream (entry.Offset, entry.Size);
|
||||||
return input;
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
input.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user