mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-07-08 18:16:24 +00:00
Add support for PKWARE Data Compression Library (Blast) in Zip compression
This commit is contained in:
@@ -109,6 +109,7 @@
|
|||||||
<Compile Include="Zip\Deflate64Stream.cs"/>
|
<Compile Include="Zip\Deflate64Stream.cs"/>
|
||||||
<Compile Include="Zip\ImplodeStream.cs"/>
|
<Compile Include="Zip\ImplodeStream.cs"/>
|
||||||
<Compile Include="Zip\JpegStream.cs"/>
|
<Compile Include="Zip\JpegStream.cs"/>
|
||||||
|
<Compile Include="Zip\Blast.cs"/>
|
||||||
<Compile Include="Zip\PpmdStream.cs"/>
|
<Compile Include="Zip\PpmdStream.cs"/>
|
||||||
<Compile Include="Zip\ReduceStream.cs"/>
|
<Compile Include="Zip\ReduceStream.cs"/>
|
||||||
<Compile Include="Zip\ShrinkStream.cs"/>
|
<Compile Include="Zip\ShrinkStream.cs"/>
|
||||||
|
|||||||
58
Aaru.Compression/Zip/Blast.cs
Normal file
58
Aaru.Compression/Zip/Blast.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// Aaru Data Preservation Suite
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Blast.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Compression algorithms.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2026 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Aaru.Compression.Zip;
|
||||||
|
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
/// <summary>Implements PKWARE's Data Compression Library Implode compression algorithm</summary>
|
||||||
|
public partial class Blast
|
||||||
|
{
|
||||||
|
/// <summary>Set to <c>true</c> if this algorithm is supported, <c>false</c> otherwise.</summary>
|
||||||
|
public static bool IsSupported => Native.IsSupported;
|
||||||
|
|
||||||
|
[LibraryImport("libAaru.Compression.Native", SetLastError = true)]
|
||||||
|
private static partial int AARU_zip_blast_decode_buffer(byte[] dst_buffer, ref nint dst_size, byte[] src_buffer,
|
||||||
|
nint src_size);
|
||||||
|
|
||||||
|
/// <summary>Decodes a buffer compressed with PKWARE's Data Compression Library Implode</summary>
|
||||||
|
/// <param name="source">Encoded buffer</param>
|
||||||
|
/// <param name="destination">Buffer where to write the decoded data</param>
|
||||||
|
/// <returns>The number of decoded bytes</returns>
|
||||||
|
public static int DecodeBuffer(byte[] source, byte[] destination)
|
||||||
|
{
|
||||||
|
if(!Native.IsSupported) return 0;
|
||||||
|
|
||||||
|
nint destLen = destination.Length;
|
||||||
|
|
||||||
|
AARU_zip_blast_decode_buffer(destination, ref destLen, source, source.Length);
|
||||||
|
|
||||||
|
return (int)destLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user