Zlib directories (save paths)

I have tried several codes but none of them work the way I want.

Like zlib (no compression required, just adding all files to the data chunk will be fine) all files and subdirectories in the folder (but not the folder itself) while keeping all paths, so it will extract them for all correct paths instead of dumping all in one folder.

I got jvcl code but it doesn't compress subfolders.

procedure TJvZLibMultipleMainForm.btnCompressClick(Sender: TObject);
var
  z : TJvZlibMultiple;
begin
  ForceDirectories(ExtractFilePath(edFilename.Text));
  z := TJvZlibMultiple.Create(nil);
  Screen.Cursor := crHourGlass;
  try
    lblFilename.Caption := '';
    pbProgress.Position := 0;
    z.OnProgress := DoProgress;
    z.OnCompressingFile := DoCompressFile;
    z.CompressDirectory(edSrcFolder.Text,false,edFilename.Text);
  finally
    z.Free;
    Screen.Cursor := crDefault;
  end;
  pbProgress.Position := 0;
  lblFilename.Caption := 'Ready';
end;

      

+2


source to share


1 answer


if you want to compress subfolders you need to change this line

z.CompressDirectory(edSrcFolder.Text,False,edFilename.Text);

      

to

z.CompressDirectory(edSrcFolder.Text,True,edFilename.Text);

      



to activate recursive compression.

// compresses a Directory (recursing if Recursive is true)
// and saves the compressed result to FileName
procedure CompressDirectory(Directory: string; Recursive: Boolean; FileName: string); overload;

      

Bye.

+5


source







All Articles