mirror of
https://github.com/Barubary/dsdecmp.git
synced 2024-11-16 23:59:25 +01:00
C#: Nitro-formats will now also try to decompress files with a plaintext size of more than 0x180000. However the Supports method will first try to partially decompress the file.
This commit is contained in:
parent
a30a7ac3e3
commit
6dc34d20a6
@ -18,6 +18,8 @@ namespace DSDecmp.Formats.Nitro
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum allowed size of the decompressed file (plaintext size) allowed for Nitro
|
/// The maximum allowed size of the decompressed file (plaintext size) allowed for Nitro
|
||||||
/// Decompressors. Only used when SkipLargePlaintexts = true.
|
/// Decompressors. Only used when SkipLargePlaintexts = true.
|
||||||
|
/// If the expected plaintext size is larger that this, the 'Supports' method will partially
|
||||||
|
/// decompress the data to check if the file is OK.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int MaxPlaintextSize = 0x180000;
|
public static int MaxPlaintextSize = 0x180000;
|
||||||
|
|
||||||
@ -59,7 +61,24 @@ namespace DSDecmp.Formats.Nitro
|
|||||||
stream.Read(sizeBytes, 0, 4);
|
stream.Read(sizeBytes, 0, 4);
|
||||||
outSize = (int)IOUtils.ToNDSu32(sizeBytes, 0);
|
outSize = (int)IOUtils.ToNDSu32(sizeBytes, 0);
|
||||||
}
|
}
|
||||||
return outSize <= MaxPlaintextSize;
|
if (outSize <= MaxPlaintextSize)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stream.Position = startPosition;
|
||||||
|
this.Decompress(stream, Math.Min(Math.Min(inLength, 0x80000), MaxPlaintextSize), new System.IO.MemoryStream());
|
||||||
|
// we expect a NotEnoughDataException, since we're giving the decompressor only part of the file.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (NotEnoughDataException)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user