Zip

 

Simple archiver based on libminizip.

miyako/4d-plugin-zip


  • Updated to minizip 2.8.9

Compatibility note

There are several ways to create a zip file on macOS. Not all of them are valid for archiving apps.

  • Archive Utility

/System/Library/CoreServices/Applications

When a zip file is created via the Finder, the result is essentailly the same as using ditto with the option --sequesterRsrc.

ditto -c -k --sequesterRsrc --keepParent test test.zip 

Note: The source and destination paths are passed in the reverse order for ditto compared to zip or minizip.

drwxr-xr-x  2.1 unx        0 bx stor 19-Sep-09 14:18 test/
-rw-r--r--  2.1 unx     6148 bX defN 19-Sep-09 14:17 test/.DS_Store
drwxrwxr-x  2.1 unx        0 bx stor 19-Sep-09 14:18 __MACOSX/
drwxrwxr-x  2.1 unx        0 bx stor 19-Sep-09 14:18 __MACOSX/test/
-rw-r--r--  2.1 unx      120 bX defN 19-Sep-09 14:17 __MACOSX/test/._.DS_Store
drwxr-xr-x  2.1 unx        0 bx stor 19-Sep-09 14:16 test/folder/
lrwxr-xr-x  2.1 unx       33 b- stor 19-Sep-09 14:18 test/a
7 files, 6301 bytes uncompressed, 338 bytes compressed:  94.6%

We can assertain a few things:

  1. Invisble files are stored
  2. Symbolic links are stored
  3. Resource forks and HFS meta-data are stored in a directory named __MACOSX
  4. UNIX file attributes are stored
  5. Platform is unx

ditto

  • Minizip (zlib version)

madler/zlib/contrib/minizip

minizip test.zip test
-rw----     0.0 fat        0 b- defN 80-Jan-00 00:00 test
1 file, 0 bytes uncompressed, 2 bytes compressed:  0.0%

We can see that the program is quite limited.

  1. Invisble files are NOT stored
  2. Symbolic links are NOT stored
  3. UNIX file attributes are NOT stored
  4. Dates are NOT stored
  5. Platform is fat
  • Zip

/usr/bin/zip

zip -r -y test.zip test
Zip file size: 893 bytes, number of entries: 4
drwxr-xr-x  3.0 unx        0 bx stor 19-Sep-09 14:18 test/
-rw-r--r--  3.0 unx     6148 bx defN 19-Sep-09 14:27 test/.DS_Store
drwxr-xr-x  3.0 unx        0 bx stor 19-Sep-09 14:16 test/folder/
lrwxr-xr-x  3.0 unx       33 bx stor 19-Sep-09 14:18 test/a
  1. Invisble files are stored
  2. Symbolic links are stored
  3. UNIX file attributes are stored
  4. Platform is unx

zip

  • Minizip (nmoinvaz version)

nmoinvaz/minizip/

minizip -y test.zip test

`

Zip file size: 764 bytes, number of entries: 3
-rw-r--r--  6.3 osx     6148 bX defN 19-Sep-09 14:27 .DS_Store
drwxr-xr-x  6.3 osx        0 b- stor 19-Sep-09 14:16 folder/
lrwxr-xr-x  6.3 osx        0 bX defN 19-Sep-09 14:16 a
  1. Invisble files are stored
  2. Symbolic links are stored but the content (path) is missing
  3. UNIX file attributes are stored
  4. Platform is osx

In order to keep integrity we want the following features:

  1. Ignore invisble files
  2. Ignore Resource forks and HFS meta-data
  3. Store symbolic links with their paths
  4. Store UNIX file attributes
  5. Store dates
  6. Store platform as osx (optional)

Unfortunately, neither the madler or nmoinvaz seems to tick all boxes.

The plugin is based on the nmoinvaz minizip code with some modifications to ignore invisible files and store symbolic links with their paths. This is critical for creating a zip that can be unarchived on macOS 10.15 Catalina.

Note: If you transfer a zipped app over a network (AirDrop, email, FTP:, HTTP:, etc.) the file will be marked with some Finder attributes that will signal GateKeeper to block its execution. You can remove such attributes with xattr -r -c or xattr -r -d com.apple.quarantine.

xattr


success:=Zip (src;dst;pass;level;options;callback;codepage)
Parameter
Type
Description
src
TEXT
dst
TEXT
pass
TEXT
level
LONGINT
options
LONGINT
callback
TEXT
codepage
LONGINT
success
LONGINT

Zip options

Property Type Description
ZIP_Ignore_hidden LONGINT  
ZIP_With_attributes LONGINT  
ZIP_Without_enclosing_folder LONGINT  
ZIP_With_encryption LONGINT  
ZIP_BZ2 LONGINT  
ZIP_7Z LONGINT  

Zip Compression Level

Property Type Description
ZIP_Compression_level_default LONGINT  
ZIP_Compression_level_0 LONGINT  
ZIP_Compression_level_1 LONGINT  
ZIP_Compression_level_2 LONGINT  
ZIP_Compression_level_3 LONGINT  
ZIP_Compression_level_4 LONGINT  
ZIP_Compression_level_5 LONGINT  
ZIP_Compression_level_6 LONGINT  
ZIP_Compression_level_7 LONGINT  
ZIP_Compression_level_8 LONGINT  
ZIP_Compression_level_9 LONGINT  

Zip Charset

Property Type Description
Zip_Charset_automatic LONGINT  
{any} LONGINT windows code page
result:=Unzip (src;dst;pass;options;callback;codepage)
Parameter
Type
Description
src
TEXT
dst
TEXT
pass
TEXT
options
LONGINT
callback
TEXT
codepage
LONGINT
success
LONGINT