Recent

Author Topic: Snappy (from Google) compression and decompression  (Read 304 times)

Tomxe

  • New Member
  • *
  • Posts: 43
Snappy (from Google) compression and decompression
« on: February 13, 2025, 09:04:51 pm »
Snappy (https://github.com/google/snappy)  compression and decompression unit:
https://github.com/Xelitan/Snappy-Compression-Decompression-for-Delphi-Lazarus/
License: MIT

Code: Pascal  [Select][+][-]
  1. var F,S: TFileStream;
  2. begin
  3.   F := TFileStream.Create('test.txt', fmOpenRead);
  4.   S := TFileStream.Create('test2.snap', fmCreate);
  5.  
  6.   Snappy(F, S);
  7.   F.Free;
  8.   S.Free;
  9.  
  10.   F := TFileStream.Create('test2.snap', fmOpenRead);
  11.   S := TFileStream.Create('test22.txt', fmCreate);
  12.  
  13.   UnSnappy(F, S);
  14.   F.Free;
  15.   S.Free;
  16. end;

Code: Pascal  [Select][+][-]
  1. ShowMessage(UnSnappy(Snappy('Test')));

Code: Pascal  [Select][+][-]
  1. var Data: array of Byte;
  2.       Size: Integer;
  3.       OutData, OutData2: TBytes;
  4.       Res: Boolean;
  5. begin
  6.   Res := Snappy(@Data[0], Size, OutData); //or @Data[1] is Data is String
  7.   Res := UnSnappy(@OutData[0], Length(OutData), OutData2);

 

TinyPortal © 2005-2018