Recent

Author Topic: libarchive - pack/unpack files (with DLL)  (Read 962 times)

Tomxe

  • New Member
  • *
  • Posts: 47
libarchive - pack/unpack files (with DLL)
« on: July 26, 2025, 04:58:45 pm »
License: MIT

Code: https://github.com/Xelitan/libarchive-for-Delphi-Free-Pascal-Lazarus/

Usage:

Code: Pascal  [Select][+][-]
  1. var A: TPacker;
  2. begin
  3.   A := TPacker.Create('output.tar.xz', 'tar', 'xz');
  4.   A.AddFile('test.txt', 'test1.txt');
  5.   A.AddFile('test.txt', 'test2.txt');
  6.   A.AddDirectory('testdir');
  7.   A.Free;
  8.  


Code: Pascal  [Select][+][-]
  1. var A: TUnpacker;
  2.     Info: TFileInfo;
  3.     F: TFileStream;
  4.     Path: String;
  5. begin
  6.   A := TUnpacker.Create('archive.7z');
  7.  
  8.   while A.NextInfo(Info) do begin
  9.     Path := 'out_dir\' + Info.Path;
  10.  
  11.     ForceDirectories(ExtractFileDir(Path));
  12.  
  13.     if Info.IsDir then continue;
  14.  
  15.     F := TFileStream.Create(Path, fmCreate);
  16.  
  17.     A.ExtractTo(F);
  18.  
  19.     F.Free;
  20.   end;
  21.  
  22.   A.Free;
  23. end;

64-bit DLLs can be downloaded from Github. They should also be available on libarchive's official Github (but right now they have a 404 error).

 

TinyPortal © 2005-2018