1
0
mirror of synced 2024-12-11 23:36:01 +01:00
Switch-Toolbox/Switch_Toolbox_Library/IO/Extensions/StreamExport.cs
KillzXGaming 0c126e4155 More improvements.
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.
2019-09-15 19:13:01 -04:00

36 lines
941 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Toolbox.Library.IO
{
public static class StreamExport
{
public static byte[] ToBytes(this Stream stream)
{
using (var reader = new FileReader(stream, true))
{
return reader.ReadBytes((int)stream.Length);
}
using (var memStream = new MemoryStream())
{
stream.CopyTo(memStream);
return memStream.ToArray();
}
}
public static void ExportToFile(this Stream stream, string fileName)
{
using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Write))
{
stream.Position = 0;
stream.CopyTo(fileStream);
}
}
}
}