Advertisement
ADD09272

fast-lzma2-delphi

Oct 6th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. fast-lzma2-delphi
  2. fast-lzma2.h conversion to delphi. It's not completed yet. Let me know if you can contribute with the conversion too. You need fast-lzma2.dll to use this.
  3.  
  4. A simple example:
  5.  
  6. var
  7.  
  8. ms: tmemorystream;
  9.  
  10. outbuff: pointer;
  11.  
  12. outsize: integer;
  13.  
  14. outa: TFileStream;
  15.  
  16. begin
  17.  
  18. try
  19.  
  20. ms := tmemorystream.Create;
  21.  
  22. ms.LoadFromFile(Paramstr(1)); {Loading file to memory}
  23.  
  24. getmem(outbuff, ms.Size + 14); {Getting required memory to buffer}
  25.  
  26. outsize:=FL2_compressmt(outbuff,ms.Size+14,ms.Memory,ms.Size,9); {Compressing using fast lzma2}
  27.  
  28. outa:=TFilestream.Create(Paramstr(2), fmCreate);
  29.  
  30. outa.Writebuffer(outbuff^, outsize); {Writting to output}
  31.  
  32. outa.free;
  33.  
  34. ms.Free;
  35.  
  36. except
  37.  
  38. on E: Exception do
  39.  
  40. Writeln(ErrOutput,E.ClassName + ': ' + E.Message);
  41. end;
  42.  
  43. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement