A wrapper for LiteZip, a free and easy-to-use zip file handler, as originally published at

Allows the creation of and extraction from standard zip archives.

The emphasis is very much on the ability to extract from compatible archives automatically, as opposed to the ability to extract from any old weird format archive.
If something (from afar) does not work, you are expected to pull it apart by hand and reconstruct it (perhaps with a different tool) into something that does work.
All the files that I have created with 7-Zip have, so far, proved perfectly compatible.

UPDATE: Files created with LiteZip trigger a "Warnings: Headers Error" in 7-Zip, when extracting via the windows explorer extensions and on the Info pop-up, but not via the gui test/extract.
I got the following reply from Igor Pavlov, the creator of 7-Zip: ”It’s just warning. There is incorrect ”extra“ record in local descriptor. You can write to LiteZip developers, and suggest them to fix the problem.“
I will (/may) investigate further once 0.8.0 is shipped. Anyway, apart from that they seem to work just fine.

One use of this, of particular importance for me, is software distribution.

Requires LiteUnZip.dll (44K) and/or LiteZip.dll (40K) to be installed/distributed, but either may be absent, as long as only a subset of these routines are actually invoked.
They can be left in the builtins\ directory, or copied to the application directory.

Note: Currently 32-bit Windows only. However it is open source, I assume 64-bit and/or linux .so files could probably be built from it reasonably easily.
All versions of linux have an ‘unzip’ command line utility, which can be used instead, however, no such luck on Windows.

Fully-fledged utilities such as 7-Zip produce slightly smaller archives, and in my tests they were about 2 or 3% smaller (personally I had always planned to use those anyway).
In reality the compression routines are provided for completeness only, however in theory the decompression routines might work better when the same code base originally did the compression, not that I have any direct evidence of that. On the plus side, the compression routines (as well as the decompression routines) are really rather easy to use, perhaps even easier than any other way.

Example 1:

include builtins\LiteZip.e

atom hzip = UnzipOpenFile("")

integer numitems = UnzipGetItems(hzip,ze)
?{"numitems",numitems}  -- prints {"numitems",1156}


?UnzipFindItem(hzip,ze,"readme.txt")    -- prints 0 (ZR_OK)
?UnzipGetFileName(ze) -- prints current_dir()&"\\test\\readme.txt"

for i=1 to numitems do
    integer res = UnzipGetItem(hzip, ze, i-1)
    res = UnzipItemToFile(hzip, ze)
end for


Example 2:

include builtins\LiteZip.e

atom hzip = ZipCreateFile("")
integer res
res = ZipAddFile(hzip,"LiteZip.dll")
res = ZipAddFile(hzip,"LiteUnzip.dll")
res = ZipAddDir(hzip,"test\\LiteZip",5)
res = ZipAddFolder(hzip,"empty")
It does not get any simpler than that. You may prefer to declare res as an object, and test it for string after each step.

Not [yet] attempted:


ZipOptions (options are TZIP_OPTION_GZIP and TZIP_OPTION_ABORT only anyway)

None of those are particularly important for dealing with real files and real .zip files, but may have uses for eg ipc or embedded resources.

Note this wrapper uses an internal ZR_MESSAGES constant instead of (Unz|Z)ipFormatMessage().

I have also deliberately omitted support for passwords, but adding that should not be difficult, if ever needed, though that I frankly doubt, given how many programs now exist that can easily crack them.