2019-07-07 19:02:20 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.IO.Compression;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-07-16 21:35:21 +00:00
|
|
|
|
using Toolbox.Library.IO;
|
2019-07-07 19:02:20 +00:00
|
|
|
|
|
2019-07-16 21:35:21 +00:00
|
|
|
|
namespace Toolbox.Library
|
2019-07-07 19:02:20 +00:00
|
|
|
|
{
|
2019-09-15 23:13:01 +00:00
|
|
|
|
public class ZlibGZ : ICompressionFormat
|
2019-07-07 19:02:20 +00:00
|
|
|
|
{
|
2019-09-15 23:13:01 +00:00
|
|
|
|
public bool IsBigEndian = true;
|
2019-07-07 19:02:20 +00:00
|
|
|
|
|
2019-09-15 23:13:01 +00: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 19:02:20 +00:00
|
|
|
|
{
|
2019-09-15 23:13:01 +00:00
|
|
|
|
if (Utils.GetExtension(fileName) != ".gz")
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return STLibraryCompression.ZLIB_GZ.IsCompressed(stream);
|
2019-07-07 19:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanCompress { get; } = true;
|
|
|
|
|
|
|
|
|
|
public Stream Decompress(Stream stream)
|
|
|
|
|
{
|
2019-09-15 23:13:01 +00:00
|
|
|
|
return STLibraryCompression.ZLIB_GZ.Decompress(stream);
|
2019-07-07 19:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Stream Compress(Stream stream)
|
|
|
|
|
{
|
2019-09-15 23:13:01 +00:00
|
|
|
|
return STLibraryCompression.ZLIB_GZ.Compress(stream, IsBigEndian);
|
2019-07-07 19:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|