VCLZip: Virtual directories in a zip file

We have files that are grouped into different categories, for example CatA.. CatD. Each category has an associated folder that the user can configure. For example, CatAgoes to C:\Path\To\CatA, CatBto C:\Path\To\CatB, CatCand CatDto go to C:\Path\To\CatCD.

Now I want to backup and restore these files to / from a zip file according to the type specification

[CatA]
SomeFile.abc
*.txt

[CatB]
File3.xyz
File4.xyz
.
.
.

The resulting zip file should have a structure like

CatA
  SomeFile.abc
  aaa.txt
  bbb.txt
  ccc.txt
CatB
  File3.xyz
  File4.xyz
.
.
.

VCLZip Zip UnZip(Selected) Pathname. Zip/UnZip(Selected), VCLZip , .

TVCLUnzip.FilesList.Objects TVCLUnzip.FilesList.Objects, "" OnStartZip, ZipHeader.directory, , , , . ?

+5
1

. TVCLZip.FileList TVclZIP.ExcludeList

VCLZip.FileList.Add('C:\Path\To\CatA\*.txt');
VCLZip.FileList.Add('C:\Path\To\CatA\SomeFile.abc');
VCLZip.FileList.Add('C:\Path\To\CatB\File3.xyz');
......

TVCLZip.OnStartZip. , . :

procedure TMainForm.VCLZipStartZip( Sender: TObject; FName: String;  var ZipHeader: TZipHeaderInfo; var Skip: Boolean );
var Dest: String;

begin
try
   Dest:=ExtractFilePath(FName);
   Dest:=StringReplace(Dest,'C:\Path\To\','' ,[rfReplaceAll,rfIgnoreCase]);
   ZipHeader.directory:=Dest;
end;

ZipHeader.directory , ZIP .

0

All Articles