1
0
mirror of synced 2024-11-28 01:10:51 +01:00

Decompress zlib files that start after 4 bytes

This commit is contained in:
KillzXGaming 2019-07-02 21:39:19 -04:00
parent 131a7b940a
commit 2a99dd3308
7 changed files with 18 additions and 1 deletions

Binary file not shown.

View File

@ -46,7 +46,7 @@ namespace FirstPlugin
public FileEntry(string Name)
{
Text = Name;
Text = Name.Replace(" ", string.Empty).RemoveIllegaleFolderNameCharacters();
if (Utils.HasExtension(Name, ".cbfmd") ||
Utils.HasExtension(Name, ".cbfa") ||

View File

@ -165,12 +165,17 @@ namespace Switch_Toolbox.Library.IO
fileReader.Position = 0;
ushort MagicHex2 = fileReader.ReadUInt16();
//Another hacky magic check if decomp size is first
fileReader.Position = 4;
ushort MagicHex3 = fileReader.ReadUInt16();
Stream stream;
if (data != null)
stream = new MemoryStream(data);
else
stream = File.OpenRead(FileName);
//Note this method will soon be how all compression formats are handled rather than being checked here
foreach (ICompressionFormat compressionFormat in FileManager.GetCompressionFormats())
{
if (compressionFormat.Identify(stream))
@ -218,6 +223,18 @@ namespace Switch_Toolbox.Library.IO
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
CompressionType.Zlib, DecompressedFileSize, CompressedFileSize);
}
if (MagicHex3 == 0x789C || MagicHex3 == 0x78DA && CompType == CompressionType.None)
{
if (data == null)
data = File.ReadAllBytes(FileName);
fileReader.Position = 0;
int OuSize = fileReader.ReadInt32();
int InSize = data.Length - 4;
data = STLibraryCompression.ZLIB.Decompress(fileReader.getSection(4, InSize));
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
CompressionType.Zlib, DecompressedFileSize, CompressedFileSize);
}
if (Path.GetExtension(FileName) == ".carc" && CompType == CompressionType.None)
{
if (data == null)