Skip to content

Commit

Permalink
Added the possibility to add a password when creating a zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVandezande committed Aug 9, 2012
1 parent cb2727e commit d8a6f48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions RemObjects.Train/API/Zip.pas
Expand Up @@ -16,7 +16,7 @@ interface
public
method &Register(aServices: IApiRegistrationServices);
[WrapAs('zip.compress', SkipDryRun := true)]
class method ZipCompress(aServices: IApiRegistrationServices; ec: ExecutionContext; zip: String; aInputFolder: String; aFileMasks: String; aRecurse: Boolean := true);
class method ZipCompress(aServices: IApiRegistrationServices; ec: ExecutionContext; zip: String; aInputFolder: String; aFileMasks: String; aRecurse: Boolean := true; aPassword: String := nil);

[WrapAs('zip.list', SkipDryRun := true, Important := false)]
class method ZipList(aServices: IApiRegistrationServices; ec: ExecutionContext; zip: String): array of ZipEntryData;
Expand Down Expand Up @@ -47,7 +47,7 @@ implementation
;
end;

class method ZipRegistration.ZipCompress(aServices: IApiRegistrationServices; ec: ExecutionContext; zip: String; aInputFolder: String; aFileMasks: String; aRecurse: Boolean);
class method ZipRegistration.ZipCompress(aServices: IApiRegistrationServices; ec: ExecutionContext; zip: String; aInputFolder: String; aFileMasks: String; aRecurse: Boolean; aPassword: String := nil);
begin
zip := aServices.ResolveWithBase(ec,zip);
//if System.IO.File.Exists(zip) then System.IO.File.Delete(zip);
Expand All @@ -57,6 +57,7 @@ implementation
if not aInputFolder.EndsWith(System.IO.Path.DirectorySeparatorChar) then
aInputFolder := aInputFolder + System.IO.Path.DirectorySeparatorChar;
var lZip := new Ionic.Zip.ZipFile();
if not String.IsNullOrEmpty(aPassword) then lZip.Password := aPassword;
lZip.ParallelDeflateThreshold := -1;
for each mask in aFileMasks.Split([';'], StringSplitOptions.RemoveEmptyEntries) do
for each el in System.IO.Directory.EnumerateFiles(aInputFolder, mask, if aRecurse then System.IO.SearchOption.AllDirectories else System.IO.SearchOption.TopDirectoryOnly) do begin
Expand Down

0 comments on commit d8a6f48

Please sign in to comment.