Archived Forum Post

Index of archived forum posts

Question:

Password protected Zip trouble on MAC OS X?

Aug 22 '12 at 10:42

I am using your trail for Mac OS X C++ library, "libchilkat.dylib", to test zip with password protected. Its not working for image files(jpg, png) but working for other files like mp3, etc .. When I try to unzip using Mac's default Archive Utility then file error message is shown. Please check the attached snapshot.

do I need to do anything special to zip (with password enabled) image files ?

Environment: - Mac OS X Lion (10.7) - Xcode 4.3.3


Answer

The password-protected .zip's created w/ Chilkat open with other tools such as WinZip, or StuffIt Expander, but not with the Mac's default "Archive Utility".

Maybe there is an issue in Mac's "Archive Utility" itself.


Answer

It sounds like a defect in the Mac's default "Archive Utility". It probably cannot handle password-protected entries within the .zip that have no compression. Many files, such as JPG, are already compressed and trying to compress further is computationally very expensive, and results in very little or no additional size reduction. Therefore, Chilkat Zip automatically uses a compression level = 0 (no compression) for these types of files. See the AddNoCompressExtension method in the Zip online reference documentation.

public void AddNoCompressExtension(string fileExtension);

Attempting to compress already-compressed data is usually a waste of CPU cycles with little or no benefit. In fact, it is possible that attempting to compress already-compressed data results in a slightly increased size. The Zip file format allows for files to be "stored" rather than compressed. This allows the file data to be streamed directly into a .zip without compression. An instance of the Zip object has an internal list of "no compress" extensions. A filename with a "no compress" extension is "stored" rather than compressed. Additional "no compress" extensions may be added by calling this method (once per file extension). You should pass the file extension, such as ".xyz" in fileExtension.

"no compress" extensions may be removed by calling RemoveNoCompressExtension.

The default "no compress" extensions are: .zip, .gif, .jpg, .gz, .rar, .jar, .tgz, .bz2, .z, .rpm, .msi, .png

You might try calling RemoveNoCompressExtension for each of the default "no compress" extensions.