From b1b9230146de01cea7f492e756c73dab7e10af78 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Tue, 18 Jun 2019 15:48:18 -0400 Subject: [PATCH] Quick SDF fix --- Switch_FileFormatsMain/FileFormats/Archives/SDF.cs | 9 +++++---- Switch_Toolbox_Library/FileFormats/TGA.cs | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Switch_FileFormatsMain/FileFormats/Archives/SDF.cs b/Switch_FileFormatsMain/FileFormats/Archives/SDF.cs index aa207e04..855b444f 100644 --- a/Switch_FileFormatsMain/FileFormats/Archives/SDF.cs +++ b/Switch_FileFormatsMain/FileFormats/Archives/SDF.cs @@ -104,8 +104,6 @@ namespace FirstPlugin //Read last id endId = new SDFTOC_ID(reader); - MessageBox.Show("Note! Support for this format is experimental. The tool will only load < 4000 files atm due to slow loading"); - for (int i = 0; i < FileEntries.Count; i++) files.Add(FileEntries[i]); } @@ -199,6 +197,10 @@ namespace FirstPlugin set { base.FileData = value;} } + public override string FileSize => STMath.GetFileSize((long)DecompressedSize, 4); + + public override object DisplayProperties => this; + public override IFileFormat OpenFile() { var FileFormat = STFileLoader.OpenFileFormat( @@ -226,8 +228,7 @@ namespace FirstPlugin if (!Directory.Exists(FolerPath)) Directory.CreateDirectory(FolerPath); - block.Dispose(); - return stream.getSection((int)Offset, (int)DecompressedSize); + Data.Add(stream.getSection((int)Offset, (int)DecompressedSize)); } else { diff --git a/Switch_Toolbox_Library/FileFormats/TGA.cs b/Switch_Toolbox_Library/FileFormats/TGA.cs index d901cc95..6b636cbd 100644 --- a/Switch_Toolbox_Library/FileFormats/TGA.cs +++ b/Switch_Toolbox_Library/FileFormats/TGA.cs @@ -39,6 +39,9 @@ namespace Switch_Toolbox.Library { using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true)) { + if (reader.BaseStream.Length < 30) + return false; + reader.Position = reader.BaseStream.Length - 18; bool IsValidMagic = reader.ReadString(10) == MagicFileConstant; return IsValidMagic || Utils.GetExtension(FileName) == ".tga";