Recent

Author Topic: LZ4 Compression and Decompression for Lazarus  (Read 557 times)

Tomxe

  • New Member
  • *
  • Posts: 37
LZ4 Compression and Decompression for Lazarus
« on: February 14, 2025, 11:32:00 pm »
License: MIT
https://github.com/Xelitan/LZ4-Compression-Decompression-for-Delphi-Lazarus

Usage examples:
Code: Pascal  [Select][+][-]
  1. var F,S: TFileStream;
  2.     Size: Integer;
  3. begin
  4.   LZ4_COMPRESSION := 1; //small files but slow
  5.   LZ4_COMPRESSION := 50; //bigger files, faster
  6.  
  7.   F := TFileStream.Create('input.txt', fmOpenRead);
  8.   S := TFileStream.Create('output.lz4', fmCreate);
  9.   LZ4(F, S);
  10.   Size := F.Size;
  11.   F.Free;
  12.   S.Free;
  13.  
  14.   F := TFileStream.Create('output.lz4', fmOpenRead);
  15.   S := TFileStream.Create('output.txt', fmCreate);
  16.   UnLZ4(F, S, Size);
  17.   F.Free;
  18.   S.Free;
  19. end;

Code: Pascal  [Select][+][-]
  1. ShowMessage(UnLZ4(LZ4('Hello World')));

cdbc

  • Hero Member
  • *****
  • Posts: 1943
    • http://www.cdbc.dk
Re: LZ4 Compression and Decompression for Lazarus
« Reply #1 on: February 15, 2025, 12:19:49 am »
Hi
It might be a good idea, to mention that it's winders only...
Otherwise nifty...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Tomxe

  • New Member
  • *
  • Posts: 37
Re: LZ4 Compression and Decompression for Lazarus
« Reply #2 on: February 15, 2025, 01:46:48 am »
If you replace .DLL with Linux's .SO it should work fine on Linux.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5899
  • Compiler Developer
Re: LZ4 Compression and Decompression for Lazarus
« Reply #3 on: February 15, 2025, 03:48:34 pm »
My remarks from here apply for this unit as well.

Okoba

  • Hero Member
  • *****
  • Posts: 616
Re: LZ4 Compression and Decompression for Lazarus
« Reply #4 on: February 16, 2025, 10:31:11 am »
@Tomxe you are doing great. Thank you.
If you can prepare and release or link to DLL for other platforms, it would be better too.

Tomxe

  • New Member
  • *
  • Posts: 37
Re: LZ4 Compression and Decompression for Lazarus
« Reply #5 on: February 16, 2025, 05:22:02 pm »
Here's how you can use this on Debians (Debian, Ubuntu, Kubuntu, Mint etc.):

1) apt install apt-file
2) apt install liblz4-dev
3) apt-file search liblz4.so
It will list you how your liblz4.so files are named *exactly* and where they are
In my case I have:
/usr/lib/x86_64-linux-gnu/liblz4.so.1

4) Open LZ4Lib.pas and edit  const LZ4_LIB
5) Change the value of that const. In my case to 'liblz4.so.1'
6) Compile and run

 

TinyPortal © 2005-2018