diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 4c1d201e..8418a140 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index e34a4178..c7ba5797 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index f3ef91f2..3e564199 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index a64fc58f..25a763ac 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index ba633624..b85e863a 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/IO/STFileLoader.cs b/Switch_Toolbox_Library/IO/STFileLoader.cs index 776e4b08..4c5e0aa9 100644 --- a/Switch_Toolbox_Library/IO/STFileLoader.cs +++ b/Switch_Toolbox_Library/IO/STFileLoader.cs @@ -33,7 +33,8 @@ namespace Switch_Toolbox.Library.IO public static IFileFormat OpenFileFormat(string FileName, Type[] FileTypes, byte[] data = null) { - CheckCompression(FileName, data); + //Todo. Create a compression list like IFileFormat to decompress via an Identiy method + data = CheckCompression(FileName, data); Stream stream; if (data != null) @@ -60,6 +61,8 @@ namespace Switch_Toolbox.Library.IO { CheckCompression(FileName, data); + MessageBox.Show((data != null).ToString()); + Stream stream; if (data != null) stream = new MemoryStream(data); @@ -75,27 +78,28 @@ namespace Switch_Toolbox.Library.IO return null; } - private static void CheckCompression(string FileName, byte[] data) + private static byte[] CheckCompression(string FileName, byte[] data) { if (data != null) { using (var reader = new FileReader(data)) { - DecompressData(reader, FileName, data); + return DecompressData(reader, FileName, data); } } else { using (var reader = new FileReader(FileName)) { - DecompressData(reader, FileName, data); + return DecompressData(reader, FileName, data); } } } - private static void DecompressData(FileReader reader, string FileName, byte[] data) + private static byte[] DecompressData(FileReader reader, string FileName, byte[] data) { reader.ByteOrder = ByteOrder.BigEndian; + reader.Position = 0; uint MagicHex = reader.ReadUInt32(); string Magic = reader.ReadMagic(0, 4); reader.Position = 0; @@ -103,17 +107,19 @@ namespace Switch_Toolbox.Library.IO if (Magic == "Yaz0") { if (data != null) - data = EveryFileExplorer.YAZ0.Decompress(data); + return EveryFileExplorer.YAZ0.Decompress(data); else - data = EveryFileExplorer.YAZ0.Decompress(FileName); + return EveryFileExplorer.YAZ0.Decompress(FileName); } if (MagicHex == 0x28B52FFD || MagicHex == 0xFD2FB528) { if (data != null) - data = STLibraryCompression.ZSTD.Decompress(data); + return STLibraryCompression.ZSTD.Decompress(data); else - data = STLibraryCompression.ZSTD.Decompress(File.ReadAllBytes(FileName)); + return STLibraryCompression.ZSTD.Decompress(File.ReadAllBytes(FileName)); } + + return data; } ///