1
0
mirror of synced 2024-12-05 04:17:59 +01:00
Switch-Toolbox/Switch_Toolbox_Library/Compression/Formats/ZlibGZ.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2019-07-07 21:02:20 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
using Toolbox.Library.IO;
2019-07-07 21:02:20 +02:00
namespace Toolbox.Library
2019-07-07 21:02:20 +02:00
{
public class ZlibGZ : ICompressionFormat
2019-07-07 21:02:20 +02:00
{
public bool IsBigEndian = true;
2019-07-07 21:02:20 +02:00
public string[] Description { get; set; } = new string[] { "ZLIB GZ" };
public string[] Extension { get; set; } = new string[] { "*.gz", };
public bool Identify(Stream stream, string fileName)
2019-07-07 21:02:20 +02:00
{
if (Utils.GetExtension(fileName) != ".gz")
return false;
return STLibraryCompression.ZLIB_GZ.IsCompressed(stream);
2019-07-07 21:02:20 +02:00
}
public bool CanCompress { get; } = true;
public Stream Decompress(Stream stream)
{
return STLibraryCompression.ZLIB_GZ.Decompress(stream);
2019-07-07 21:02:20 +02:00
}
public Stream Compress(Stream stream)
{
return STLibraryCompression.ZLIB_GZ.Compress(stream, IsBigEndian);
2019-07-07 21:02:20 +02:00
}
}
}