|
@@ -361,7 +361,7 @@ Type
|
|
property CRC32: LongWord read FCRC32 write FCRC32;
|
|
property CRC32: LongWord read FCRC32 write FCRC32;
|
|
end;
|
|
end;
|
|
|
|
|
|
- TOnCustomOutputEvent = Procedure(Sender : TObject; var AStream : TStream; AItem : TFullZipFileEntry; AClosing : Boolean) of object;
|
|
|
|
|
|
+ TOnCustomStreamEvent = Procedure(Sender : TObject; var AStream : TStream; AItem : TFullZipFileEntry) of object;
|
|
|
|
|
|
{ TFullZipFileEntries }
|
|
{ TFullZipFileEntries }
|
|
|
|
|
|
@@ -377,14 +377,14 @@ Type
|
|
|
|
|
|
TUnZipper = Class(TObject)
|
|
TUnZipper = Class(TObject)
|
|
Private
|
|
Private
|
|
- FOnCustomOutput: TOnCustomOutputEvent;
|
|
|
|
|
|
+ FOnCreateStream: TOnCustomStreamEvent;
|
|
|
|
+ FOnDoneStream: TOnCustomStreamEvent;
|
|
FUnZipping : Boolean;
|
|
FUnZipping : Boolean;
|
|
FBufSize : LongWord;
|
|
FBufSize : LongWord;
|
|
FFileName : String; { Name of resulting Zip file }
|
|
FFileName : String; { Name of resulting Zip file }
|
|
FOutputPath : String;
|
|
FOutputPath : String;
|
|
FEntries : TFullZipFileEntries;
|
|
FEntries : TFullZipFileEntries;
|
|
FFiles : TStrings;
|
|
FFiles : TStrings;
|
|
- FUseCustomOutputStream: Boolean;
|
|
|
|
FZipFile : TFileStream; { I/O file variables }
|
|
FZipFile : TFileStream; { I/O file variables }
|
|
LocalHdr : Local_File_Header_Type;
|
|
LocalHdr : Local_File_Header_Type;
|
|
CentralHdr : Central_File_Header_Type;
|
|
CentralHdr : Central_File_Header_Type;
|
|
@@ -418,14 +418,14 @@ Type
|
|
Procedure Examine;
|
|
Procedure Examine;
|
|
Public
|
|
Public
|
|
Property BufferSize : LongWord Read FBufSize Write SetBufSize;
|
|
Property BufferSize : LongWord Read FBufSize Write SetBufSize;
|
|
- Property OnCustomOutput : TOnCustomOutputEvent Read FOnCustomOutput Write FOnCustomOutput;
|
|
|
|
|
|
+ Property OnCreateStream : TOnCustomStreamEvent Read FOnCreateStream Write FOnCreateStream;
|
|
|
|
+ Property OnDoneStream : TOnCustomStreamEvent Read FOnDoneStream Write FOnDoneStream;
|
|
Property OnPercent : Integer Read FOnPercent Write FOnPercent;
|
|
Property OnPercent : Integer Read FOnPercent Write FOnPercent;
|
|
Property OnProgress : TProgressEvent Read FOnProgress Write FOnProgress;
|
|
Property OnProgress : TProgressEvent Read FOnProgress Write FOnProgress;
|
|
Property OnStartFile : TOnStartFileEvent Read FOnStartFile Write FOnStartFile;
|
|
Property OnStartFile : TOnStartFileEvent Read FOnStartFile Write FOnStartFile;
|
|
Property OnEndFile : TOnEndOfFileEvent Read FOnEndOfFile Write FOnEndOfFile;
|
|
Property OnEndFile : TOnEndOfFileEvent Read FOnEndOfFile Write FOnEndOfFile;
|
|
Property FileName : String Read FFileName Write SetFileName;
|
|
Property FileName : String Read FFileName Write SetFileName;
|
|
Property OutputPath : String Read FOutputPath Write SetOutputPath;
|
|
Property OutputPath : String Read FOutputPath Write SetOutputPath;
|
|
- Property UseCustomOutputStream : Boolean Read FUseCustomOutputStream Write FUseCustomOutputStream;
|
|
|
|
Property Files : TStrings Read FFiles;
|
|
Property Files : TStrings Read FFiles;
|
|
Property Entries : TFullZipFileEntries Read FEntries;
|
|
Property Entries : TFullZipFileEntries Read FEntries;
|
|
end;
|
|
end;
|
|
@@ -1515,16 +1515,17 @@ Begin
|
|
OldDirectorySeparators:=AllowDirectorySeparators;
|
|
OldDirectorySeparators:=AllowDirectorySeparators;
|
|
AllowDirectorySeparators:=[DirectorySeparator];
|
|
AllowDirectorySeparators:=[DirectorySeparator];
|
|
Path:=ExtractFilePath(OutFileName);
|
|
Path:=ExtractFilePath(OutFileName);
|
|
-
|
|
|
|
- If FUseCustomOutputStream and Assigned(FOnCustomOutput) then
|
|
|
|
- FOnCustomOutput(Self, OutStream, Item, False)
|
|
|
|
- Else
|
|
|
|
- Begin
|
|
|
|
|
|
+ OutStream:=Nil;
|
|
|
|
+ If Assigned(FOnCreateStream) then
|
|
|
|
+ FOnCreateStream(Self, OutStream, Item);
|
|
|
|
+ // If FOnCreateStream didn't create one, we create one now.
|
|
|
|
+ If (OutStream=Nil) then
|
|
|
|
+ Begin
|
|
if (Path<>'') then
|
|
if (Path<>'') then
|
|
ForceDirectories(Path);
|
|
ForceDirectories(Path);
|
|
AllowDirectorySeparators:=OldDirectorySeparators;
|
|
AllowDirectorySeparators:=OldDirectorySeparators;
|
|
OutStream:=TFileStream.Create(OutFileName,fmCreate);
|
|
OutStream:=TFileStream.Create(OutFileName,fmCreate);
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
|
|
|
|
Result:=True;
|
|
Result:=True;
|
|
If Assigned(FOnStartFile) then
|
|
If Assigned(FOnStartFile) then
|
|
@@ -1535,9 +1536,9 @@ End;
|
|
Procedure TUnZipper.CloseOutput(Item : TFullZipFileEntry; var OutStream: TStream);
|
|
Procedure TUnZipper.CloseOutput(Item : TFullZipFileEntry; var OutStream: TStream);
|
|
|
|
|
|
Begin
|
|
Begin
|
|
- if FUseCustomOutputStream and Assigned(FOnCustomOutput) then
|
|
|
|
|
|
+ if Assigned(FOnDoneStream) then
|
|
begin
|
|
begin
|
|
- FOnCustomOutput(Self, OutStream, Item, True);
|
|
|
|
|
|
+ FOnDoneStream(Self, OutStream, Item);
|
|
OutStream := nil;
|
|
OutStream := nil;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
@@ -1688,7 +1689,7 @@ Begin
|
|
ReadZipHeader(Item, ZMethod);
|
|
ReadZipHeader(Item, ZMethod);
|
|
OutputFileName:=Item.DiskFileName;
|
|
OutputFileName:=Item.DiskFileName;
|
|
|
|
|
|
- IsCustomStream := FUseCustomOutputStream and Assigned(FOnCustomOutput);
|
|
|
|
|
|
+ IsCustomStream := Assigned(FOnCreateStream);
|
|
|
|
|
|
|
|
|
|
if (IsCustomStream = False) and (FOutputPath<>'') then
|
|
if (IsCustomStream = False) and (FOutputPath<>'') then
|
|
@@ -1697,7 +1698,7 @@ Begin
|
|
IsLink := Item.IsLink;
|
|
IsLink := Item.IsLink;
|
|
|
|
|
|
{$IFNDEF UNIX}
|
|
{$IFNDEF UNIX}
|
|
- if IsLink and (IsCustomStream := False) then
|
|
|
|
|
|
+ if IsLink and Not IsCustomStream then
|
|
begin
|
|
begin
|
|
{$warning TODO: Implement symbolic link creation for non-unix}
|
|
{$warning TODO: Implement symbolic link creation for non-unix}
|
|
IsLink := False;
|
|
IsLink := False;
|
|
@@ -1705,7 +1706,7 @@ Begin
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
|
|
- if IsCustomStream = True then
|
|
|
|
|
|
+ if IsCustomStream then
|
|
begin
|
|
begin
|
|
try
|
|
try
|
|
OpenOutput(OutputFileName, FOutStream, Item);
|
|
OpenOutput(OutputFileName, FOutStream, Item);
|
|
@@ -1746,7 +1747,7 @@ Begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- if IsCustomStream = False then
|
|
|
|
|
|
+ if Not IsCustomStream then
|
|
begin
|
|
begin
|
|
// set attributes
|
|
// set attributes
|
|
FileSetDate(OutputFileName, DateTimeToFileDate(Item.DateTime));
|
|
FileSetDate(OutputFileName, DateTimeToFileDate(Item.DateTime));
|