From bb436b35e82df73dea7dcec282f42f754a320385 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Wed, 18 Sep 2019 21:13:02 -0400 Subject: [PATCH] Quick fix for decompressing incase a check fails or is inaccurate --- Switch_Toolbox_Library/IO/STFileLoader.cs | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Switch_Toolbox_Library/IO/STFileLoader.cs b/Switch_Toolbox_Library/IO/STFileLoader.cs index 863d98b4..64752621 100644 --- a/Switch_Toolbox_Library/IO/STFileLoader.cs +++ b/Switch_Toolbox_Library/IO/STFileLoader.cs @@ -183,24 +183,33 @@ namespace Toolbox.Library.IO if (stream.Length < 8) return null; - //Check all supported compression formats and decompress. Then loop back - if (!Compressed) + //Try catch incase it fails, continute to load the file anyways if the check may be false + try { - foreach (ICompressionFormat compressionFormat in FileManager.GetCompressionFormats()) + //Check all supported compression formats and decompress. Then loop back + if (!Compressed) { - stream.Position = streamStartPos; - if (compressionFormat.Identify(stream, FileName)) + foreach (ICompressionFormat compressionFormat in FileManager.GetCompressionFormats()) { stream.Position = streamStartPos; + if (compressionFormat.Identify(stream, FileName)) + { + stream.Position = streamStartPos; - stream = compressionFormat.Decompress(stream); - CompressedSize = stream.Length; + stream = compressionFormat.Decompress(stream); + CompressedSize = stream.Length; - return OpenFileFormat(stream, FileName, LeaveStreamOpen, InArchive, - true, compressionFormat, DecompressedSize, CompressedSize); + return OpenFileFormat(stream, FileName, LeaveStreamOpen, InArchive, + true, compressionFormat, DecompressedSize, CompressedSize); + } } } } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + stream.Position = streamStartPos; foreach (IFileFormat fileFormat in FileManager.GetFileFormats())