mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 14:30:26 +00:00
0c126e4155
Rewrote the compression handling from scatch. It's way easier and cleaner to add new formats code wise as it's handled like file formats. Added wip TVOL support (Touhou Azure Reflections) Added XCI support. Note I plan to improve NSP, XCI, NCA, etc later for exefs exporting. The compression rework now compresses via streams, so files get decompressed properly within archives as streams. Added hyrule warriors bin.gz compression along with archive rebuilding. Note i do not have texture rebuilding done just yet.
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Threading.Tasks;
|
|
using Toolbox.Library.IO;
|
|
|
|
namespace Toolbox.Library
|
|
{
|
|
public class MIO0 : ICompressionFormat
|
|
{
|
|
public string[] Description { get; set; } = new string[] { "MIO0" };
|
|
public string[] Extension { get; set; } = new string[] { "*.mio0" };
|
|
|
|
public bool Identify(Stream stream, string fileName)
|
|
{
|
|
using (var reader = new FileReader(stream, true))
|
|
{
|
|
return reader.CheckSignature(4, "MIO0");
|
|
}
|
|
}
|
|
|
|
public bool CanCompress { get; } = true;
|
|
|
|
public Stream Decompress(Stream stream)
|
|
{
|
|
return new MemoryStream(Decompress(stream.ToArray()));
|
|
}
|
|
|
|
public static byte[] Decompress(byte[] data)
|
|
{
|
|
List<byte> output = new List<byte>();
|
|
|
|
using (var inputFile = new FileReader(data))
|
|
using (var reader = new FileReader(data))
|
|
{
|
|
uint magicNumber = reader.ReadUInt32();
|
|
uint decompressedSize = reader.ReadUInt32();
|
|
uint compressedOffset = reader.ReadUInt32();
|
|
uint uncompressedOffset = reader.ReadUInt32();
|
|
|
|
}
|
|
|
|
return output.ToArray();
|
|
}
|
|
|
|
public Stream Compress(Stream stream)
|
|
{
|
|
return new MemoryStream();
|
|
}
|
|
}
|
|
}
|