UltimateZoneBuilder/Source/Core/GZBuilder/Data/SharpCompressHelper.cs
MaxED dc840605aa Added emergency map backup system (EMBS). When the editor crashes, it will try to export a backup copy of the map structures. When the same map is loaded again, it will ask the user if he wants to restore the map.
High-DPI: fixed many issues with incorrect controls size (Tag selector width, Comment Editor size, icons size, tabs size etc.).
Cosmetic: changed map geometry dragging undo messages to more descriptive ones.
Fixed, Textures Browser, cosmetic: "Show textures in subdirectories" checkbox should be repositioned when "Long texture names" one is invisible.
Updated ZDoom_DECORATE.cfg (added A_SetFloatSpeed + a couple of fixes).
2015-09-25 13:20:53 +00:00

38 lines
975 B
C#

using System.IO;
using SharpCompress.Compressor;
using SharpCompress.Compressor.BZip2;
namespace CodeImp.DoomBuilder.GZBuilder.Data
{
internal static class SharpCompressHelper
{
internal static MemoryStream CompressStream(Stream stream)
{
byte[] arr = new byte[stream.Length];
stream.Read(arr, 0, (int)stream.Length);
MemoryStream ms = new MemoryStream();
BZip2Stream bzip = new BZip2Stream(ms, CompressionMode.Compress, true, false);
bzip.Write(arr, 0, arr.Length);
bzip.Close();
return ms;
}
internal static MemoryStream DecompressStream(Stream stream)
{
stream.Seek(0, SeekOrigin.Begin);
BZip2Stream bzip = new BZip2Stream(stream, CompressionMode.Decompress, false, false);
byte[] buffer = new byte[16 * 1024];
MemoryStream ms = new MemoryStream();
int read;
while ((read = bzip.Read(buffer, 0, buffer.Length)) > 0)
ms.Write(buffer, 0, read);
return ms;
}
}
}