mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Bug [0002348] Cannot open empty zip files
(cherry picked from commit a6cdf056fc)
This commit is contained in:
parent
1ff352cddc
commit
8b7f395d12
1 changed files with 9 additions and 0 deletions
|
|
@ -660,6 +660,7 @@ uses
|
|||
function VerifyZip(Strm : TStream) : TAbArchiveType;
|
||||
{ determine if stream appears to be in PkZip format }
|
||||
var
|
||||
Empty : TAbZipEndOfCentralDirectoryRecord;
|
||||
Footer : TAbZipEndOfCentralDirectoryRecord;
|
||||
Sig : LongInt;
|
||||
TailPosition : int64;
|
||||
|
|
@ -681,6 +682,8 @@ begin
|
|||
if (Strm.Read(Footer, SizeOf(Footer)) = SizeOf(Footer)) and
|
||||
(Footer.Signature = Ab_ZipEndCentralDirectorySignature) then
|
||||
begin
|
||||
Empty:= Default(TAbZipEndOfCentralDirectoryRecord);
|
||||
Empty.Signature:= Ab_ZipEndCentralDirectorySignature;
|
||||
{ check Central Directory Offset }
|
||||
if (Footer.DirectoryOffset = High(LongWord)) or
|
||||
((Strm.Seek(Footer.DirectoryOffset, soBeginning) = Footer.DirectoryOffset) and
|
||||
|
|
@ -691,6 +694,12 @@ begin
|
|||
Result := atZip
|
||||
else
|
||||
Result := atSpannedZip;
|
||||
end
|
||||
{ empty archive }
|
||||
else if (Strm.Size = SizeOf(Footer)) and
|
||||
(CompareMem(@Footer, @Empty, SizeOf(Footer))) then
|
||||
begin
|
||||
Result := atZip
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue