FIX: Pack/delete progress

This commit is contained in:
Alexander Koblov 2015-04-12 10:11:13 +00:00
commit f45ba8facd
3 changed files with 31 additions and 15 deletions

View file

@ -282,6 +282,7 @@ begin
begin
Archive := AFormats[I].Create(FileNameUTF8, 0, False);
try
Archive.Tag:= @ProcessDataProcT;
AProgress:= TSevenZipUpdate.Create;
Archive.OnPassword:= AProgress.JclCompressionPassword;
Archive.OnProgress:= AProgress.JclCompressionProgress;
@ -360,6 +361,7 @@ begin
begin
Archive := AFormats[I].Create(FileNameUTF8, 0, False);
try
Archive.Tag:= @ProcessDataProcT;
AProgress:= TSevenZipUpdate.Create;
Archive.OnPassword:= AProgress.JclCompressionPassword;
Archive.OnProgress:= AProgress.JclCompressionProgress;
@ -459,13 +461,15 @@ procedure TSevenZipUpdate.JclCompressionProgress(Sender: TObject; const Value,
MaxValue: Int64);
var
Percent: Int64;
ProcessDataProc: TProcessDataProcW;
Archive: TJclUpdateArchive absolute Sender;
begin
if Assigned(ProcessDataProcT) then
if Assigned(Archive.Tag) then
begin
Percent:= 1000 + (Value * 100) div MaxValue;
ProcessDataProc:= TProcessDataProcW(Archive.Tag);
// If the user has clicked on Cancel, the function returns zero
Archive.CancelCurrentOperation:= ProcessDataProcT(PWideChar(Archive.Items[Archive.CurrentItemIndex].PackedName), -Percent) = 0;
Archive.CancelCurrentOperation:= ProcessDataProc(PWideChar(Archive.Items[Archive.CurrentItemIndex].PackedName), -Percent) = 0;
end;
end;

View file

@ -778,6 +778,7 @@ type
{ TJclCompressionArchive is not ref-counted }
TJclCompressionArchive = class(TInterfacedObject, IInterface)
private
FTag: Pointer;
FOnProgress: TJclCompressionProgressEvent;
FOnRatio: TJclCompressionRatioEvent;
FOnVolume: TJclCompressionVolumeEvent;
@ -873,6 +874,7 @@ type
property SupportsNestedArchive: Boolean read GetSupportsNestedArchive;
property CancelCurrentOperation: Boolean read FCancelCurrentOperation write FCancelCurrentOperation;
property Tag: Pointer read FTag write FTag;
end;
TJclCompressionArchiveClass = class of TJclCompressionArchive;

View file

@ -1,9 +1,9 @@
jcl/source/common/JclCompression.pas | 45 ++++++++++++++++++++++++++++++------
jcl/source/windows/sevenzip.pas | 8 +++----
2 files changed, 42 insertions(+), 11 deletions(-)
jcl/source/common/JclCompression.pas | 47 ++++++++++++++++++++++++++++++------
jcl/source/windows/sevenzip.pas | 8 +++---
2 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/jcl/source/common/JclCompression.pas b/jcl/source/common/JclCompression.pas
index e5e6a2f..9fcf6f8 100644
index e5e6a2f..6cde31b 100644
--- a/jcl/source/common/JclCompression.pas
+++ b/jcl/source/common/JclCompression.pas
@@ -44,8 +44,7 @@
@ -68,7 +68,12 @@ index e5e6a2f..9fcf6f8 100644
TJclCompressionItemProperty = (ipPackedName, ipPackedSize, ipPackedExtension,
ipFileSize, ipFileName, ipAttributes, ipCreationTime, ipLastAccessTime,
@@ -770,6 +782,7 @@ type
@@ -766,10 +778,12 @@ type
{ TJclCompressionArchive is not ref-counted }
TJclCompressionArchive = class(TInterfacedObject, IInterface)
private
+ FTag: Pointer;
FOnProgress: TJclCompressionProgressEvent;
FOnRatio: TJclCompressionRatioEvent;
FOnVolume: TJclCompressionVolumeEvent;
FOnVolumeMaxSize: TJclCompressionVolumeMaxSizeEvent;
@ -76,7 +81,7 @@ index e5e6a2f..9fcf6f8 100644
FPassword: WideString;
FVolumeIndex: Integer;
FVolumeIndexOffset: Integer;
@@ -855,6 +868,7 @@ type
@@ -855,10 +869,12 @@ type
property OnVolume: TJclCompressionVolumeEvent read FOnVolume write FOnVolume;
property OnVolumeMaxSize: TJclCompressionVolumeMaxSizeEvent read FOnVolumeMaxSize
write FOnVolumeMaxSize;
@ -84,7 +89,12 @@ index e5e6a2f..9fcf6f8 100644
property Password: WideString read FPassword write FPassword;
property SupportsNestedArchive: Boolean read GetSupportsNestedArchive;
@@ -2206,8 +2220,7 @@ const
property CancelCurrentOperation: Boolean read FCancelCurrentOperation write FCancelCurrentOperation;
+ property Tag: Pointer read FTag write FTag;
end;
TJclCompressionArchiveClass = class of TJclCompressionArchive;
@@ -2206,8 +2222,7 @@ const
implementation
uses
@ -94,7 +104,7 @@ index e5e6a2f..9fcf6f8 100644
const
JclDefaultBufferSize = 131072; // 128k
@@ -2218,6 +2231,8 @@ var
@@ -2218,6 +2233,8 @@ var
GlobalStreamFormats: TObject;
GlobalArchiveFormats: TObject;
@ -103,7 +113,7 @@ index e5e6a2f..9fcf6f8 100644
//=== { TJclCompressionStream } ==============================================
constructor TJclCompressionStream.Create(AStream: TStream);
@@ -3743,6 +3758,8 @@ begin
@@ -3743,6 +3760,8 @@ begin
end;
end;
@ -112,7 +122,7 @@ index e5e6a2f..9fcf6f8 100644
{$IFDEF MSWINDOWS}
function OpenFileStream(const FileName: TFileName; StreamAccess: TJclStreamAccess): TStream;
@@ -3887,7 +3904,7 @@ end;
@@ -3887,7 +3906,7 @@ end;
function TJclCompressionItem.GetNestedArchiveName: WideString;
var
ParentArchiveExtension, ArchiveFileName, ArchiveExtension: WideString;
@ -121,7 +131,7 @@ index e5e6a2f..9fcf6f8 100644
begin
if ipPackedName in ValidProperties then
Result := PackedName
@@ -3914,7 +3931,7 @@ begin
@@ -3914,7 +3933,7 @@ begin
else
if ArchiveFileName <> '' then
begin
@ -130,7 +140,7 @@ index e5e6a2f..9fcf6f8 100644
try
ExtensionMap.Delimiter := ';';
ExtensionMap.DelimitedText := Archive.ArchiveSubExtensions;
@@ -7422,7 +7439,14 @@ function TJclSevenzipOpenCallback.CryptoGetTextPassword(
@@ -7422,7 +7441,14 @@ function TJclSevenzipOpenCallback.CryptoGetTextPassword(
password: PBStr): HRESULT;
begin
if Assigned(password) then
@ -145,7 +155,7 @@ index e5e6a2f..9fcf6f8 100644
Result := S_OK;
end;
@@ -7456,7 +7480,14 @@ function TJclSevenzipExtractCallback.CryptoGetTextPassword(
@@ -7456,7 +7482,14 @@ function TJclSevenzipExtractCallback.CryptoGetTextPassword(
password: PBStr): HRESULT;
begin
if Assigned(password) then