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;
|
2019-07-16 23:35:21 +02:00
|
|
|
|
using Toolbox.Library.IO;
|
2019-07-07 21:02:20 +02:00
|
|
|
|
|
2019-07-16 23:35:21 +02:00
|
|
|
|
namespace Toolbox.Library
|
2019-07-07 21:02:20 +02:00
|
|
|
|
{
|
2019-09-16 01:13:01 +02:00
|
|
|
|
public class ZlibGZ : ICompressionFormat
|
2019-07-07 21:02:20 +02:00
|
|
|
|
{
|
2019-09-16 01:13:01 +02:00
|
|
|
|
public bool IsBigEndian = true;
|
2019-07-07 21:02:20 +02:00
|
|
|
|
|
2019-09-16 01:13:01 +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
|
|
|
|
{
|
2019-09-16 01:13:01 +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)
|
|
|
|
|
{
|
2019-09-16 01:13:01 +02:00
|
|
|
|
return STLibraryCompression.ZLIB_GZ.Decompress(stream);
|
2019-07-07 21:02:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Stream Compress(Stream stream)
|
|
|
|
|
{
|
2019-09-16 01:13:01 +02:00
|
|
|
|
return STLibraryCompression.ZLIB_GZ.Compress(stream, IsBigEndian);
|
2019-07-07 21:02:20 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|