1
0
mirror of synced 2024-12-12 15:51:16 +01:00
Switch-Toolbox/Switch_Toolbox_Library/Compression/Formats/Yay0.cs

64 lines
1.8 KiB
C#
Raw Normal View History

2019-07-31 23:08:00 +02:00
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Linq;
using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace Toolbox.Library
{
public class YAY0 : ICompressionFormat
{
public string[] Description { get; set; } = new string[] { "Yay0" };
public string[] Extension { get; set; } = new string[] { "*.yay0" };
public bool Identify(Stream stream, string fileName)
2019-07-31 23:08:00 +02:00
{
using (var reader = new FileReader(stream, true))
{
return reader.CheckSignature(4, "Yay0");
}
}
public bool CanCompress { get; } = false;
//Algorithm from
//https://github.com/Daniel-McCarthy/Mr-Peeps-Compressor/blob/master/PeepsCompress/PeepsCompress/Algorithm%20Classes/YAY0.cs
//License https://github.com/Daniel-McCarthy/Mr-Peeps-Compressor/blob/master/LICENSE
2019-07-31 23:08:00 +02:00
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();
2019-11-09 23:36:52 +01:00
while (output.Count < decompressedSize)
{
break;
2019-11-09 23:36:52 +01:00
}
2019-07-31 23:08:00 +02:00
}
return output.ToArray();
}
public Stream Compress(Stream stream)
{
return new MemoryStream();
}
}
}