mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
Quick fix for decompressing incase a check fails or is inaccurate
This commit is contained in:
parent
6ec78fa2c5
commit
bb436b35e8
1 changed files with 18 additions and 9 deletions
|
@ -183,24 +183,33 @@ namespace Toolbox.Library.IO
|
||||||
|
|
||||||
if (stream.Length < 8) return null;
|
if (stream.Length < 8) return null;
|
||||||
|
|
||||||
//Check all supported compression formats and decompress. Then loop back
|
//Try catch incase it fails, continute to load the file anyways if the check may be false
|
||||||
if (!Compressed)
|
try
|
||||||
{
|
{
|
||||||
foreach (ICompressionFormat compressionFormat in FileManager.GetCompressionFormats())
|
//Check all supported compression formats and decompress. Then loop back
|
||||||
|
if (!Compressed)
|
||||||
{
|
{
|
||||||
stream.Position = streamStartPos;
|
foreach (ICompressionFormat compressionFormat in FileManager.GetCompressionFormats())
|
||||||
if (compressionFormat.Identify(stream, FileName))
|
|
||||||
{
|
{
|
||||||
stream.Position = streamStartPos;
|
stream.Position = streamStartPos;
|
||||||
|
if (compressionFormat.Identify(stream, FileName))
|
||||||
|
{
|
||||||
|
stream.Position = streamStartPos;
|
||||||
|
|
||||||
stream = compressionFormat.Decompress(stream);
|
stream = compressionFormat.Decompress(stream);
|
||||||
CompressedSize = stream.Length;
|
CompressedSize = stream.Length;
|
||||||
|
|
||||||
return OpenFileFormat(stream, FileName, LeaveStreamOpen, InArchive,
|
return OpenFileFormat(stream, FileName, LeaveStreamOpen, InArchive,
|
||||||
true, compressionFormat, DecompressedSize, CompressedSize);
|
true, compressionFormat, DecompressedSize, CompressedSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
stream.Position = streamStartPos;
|
stream.Position = streamStartPos;
|
||||||
foreach (IFileFormat fileFormat in FileManager.GetFileFormats())
|
foreach (IFileFormat fileFormat in FileManager.GetFileFormats())
|
||||||
|
|
Loading…
Reference in a new issue