Browse Source

* Cosmetic changes, fixes issue #40377

(cherry picked from commit e2a54b6e7549af98a3aa9d7d81a11a099f4495aa)
Michaël Van Canneyt 2 years ago
parent
commit
b13056fcf2
1 changed files with 11 additions and 6 deletions
  1. 11 6
      packages/paszlib/src/zipper.pp

+ 11 - 6
packages/paszlib/src/zipper.pp

@@ -626,7 +626,7 @@ ResourceString
   SErrFileChange = 'Changing output file name is not allowed while (un)zipping.';
   SErrInvalidCRC = 'Invalid CRC checksum while unzipping %s.';
   SErrCorruptZIP = 'Corrupt ZIP file %s.';
-  SErrUnsupportedCompressionFormat = 'Unsupported compression format %d';
+  SErrUnsupportedCompressionFormat = 'Unsupported compression format %d.';
   SErrUnsupportedMultipleDisksCD = 'A central directory split over multiple disks is unsupported.';
   SErrMaxEntries = 'Encountered %d file entries; maximum supported is %d.';
   SErrMissingFileName = 'Missing filename in entry %d.';
@@ -635,8 +635,13 @@ ResourceString
   SErrPosTooLarge = 'Position/offset %d is larger than maximum supported %d.';
   SErrNoFileName = 'No archive filename for examine operation.';
   SErrNoStream = 'No stream is opened.';
-  SErrEncryptionNotSupported = 'Cannot unzip item "%s" : encryption is not supported.';
-  SErrPatchSetNotSupported = 'Cannot unzip item "%s" : Patch sets are not supported.';
+  SErrEncryptionNotSupported = 'Cannot unzip item "%s": encryption is not supported.';
+  SErrPatchSetNotSupported = 'Cannot unzip item "%s": patch sets are not supported.';
+
+const
+  ZIPBITFLAG_ENCRYPTION       = 1;
+  ZIPBITFLAG_SIZE_IN_DATADESC = 1 shl 3;
+  ZIPBITFLAG_PATCH_SET        = 1 shl 5;  
 
 { ---------------------------------------------------------------------
     Auxiliary
@@ -2318,7 +2323,7 @@ Begin
       // If bit 3 is set in the BitFlags, file size and CRC should be read from
       // the DataDescriptor record. For simplicity, however, we copy them from
       // the same fields of the zipfile entry.
-      if Item.FBitFlags and $0008 <> 0 then
+      if Item.FBitFlags and ZIPBITFLAG_SIZE_IN_DATADESC <> 0 then
       begin
         Uncompressed_Size := Item.Size;
         Compressed_Size := Item.CompressedSize;
@@ -2798,9 +2803,9 @@ Var
 
 Begin
   ReadZipHeader(Item, ZMethod);
-  if (Item.BitFlags and 1)<>0 then
+  if (Item.BitFlags and ZIPBITFLAG_ENCRYPTION)<>0 then
     Raise EZipError.CreateFmt(SErrEncryptionNotSupported,[Item.ArchiveFileName]);
-  if (Item.BitFlags and (1 shl 5))<>0 then
+  if (Item.BitFlags and ZIPBITFLAG_PATCH_SET)<>0 then
     Raise EZipError.CreateFmt(SErrPatchSetNotSupported,[Item.ArchiveFileName]);
   // Normalize output filename to conventions of target platform.
   // Zip file always has / path separators