Skip to content

Commit

Permalink
include optional ZipFolder to TZipWrite.AddFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Sep 8, 2023
1 parent bd73d5c commit fd4afbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/core/mormot.core.zip.pas
Expand Up @@ -673,11 +673,12 @@ TZipWrite = class(TZipAbstract)
// - you may set CompressLevel=-1 to force Z_STORED method with no deflate
// - OnAdd callback could be used to customize the process
// - IncludeVoidFolders=TRUE would include void folders entries to the zip
// - you can specify a ZipFolder to store as parent folder for the files
// - returns the number of files added
function AddFolder(const FolderName: TFileName;
const Mask: TFileName = FILES_ALL; Recursive: boolean = true;
CompressLevel: integer = 6; const OnAdd: TOnZipWriteAdd = nil;
IncludeVoidFolders: boolean = false): integer;
IncludeVoidFolders: boolean = false; ZipFolder: TFileName = ''): integer;
/// compress (using AddDeflate) the supplied files
// - you may set CompressLevel=-1 to force Z_STORED method with no deflate
procedure AddFiles(const aFiles: array of TFileName;
Expand Down Expand Up @@ -1956,7 +1957,8 @@ procedure TZipWrite.AddDeflated(const aFileName: TFileName;

function TZipWrite.AddFolder(const FolderName: TFileName;
const Mask: TFileName; Recursive: boolean; CompressLevel: integer;
const OnAdd: TOnZipWriteAdd; IncludeVoidFolders: boolean): integer;
const OnAdd: TOnZipWriteAdd; IncludeVoidFolders: boolean;
ZipFolder: TFileName): integer;

function RecursiveAdd(const fileDir, zipDir: TFileName): integer;
var
Expand Down Expand Up @@ -2006,7 +2008,9 @@ function TZipWrite.AddFolder(const FolderName: TFileName;
end;

begin
result := RecursiveAdd(IncludeTrailingPathDelimiter(FolderName), '');
if ZipFolder <> '' then
ZipFolder:= IncludeTrailingPathDelimiter(ZipFolder);
result := RecursiveAdd(IncludeTrailingPathDelimiter(FolderName), ZipFolder);
end;

procedure TZipWrite.AddFiles(const aFiles: array of TFileName;
Expand Down
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
@@ -1 +1 @@
'2.1.5852'
'2.1.5853'

0 comments on commit fd4afbc

Please sign in to comment.