Zip-Ada: Ada library for zip files (.zip). Ada programming.
Zip-Ada   20 years Zip-Ada

[NEW] LZMA compression supported.

What is Zip-Ada ?

Zip-Ada is a free, open-source programming library for dealing with the Zip compressed archive file format.
The full sources of Zip-Ada are in Ada, compilable on every compiler and for every system.
For more details, read the files zipada.txt and zip.ads from the archive below.
 
Why not call an zip or unzip executable, or use the zlib library ?
  • Independence:
    with this library you can zip and unzip data without any OS-dependent external call.
    Furthermore, you can use Zip-Ada with any data stream instead of files, for the archives as well as for the archived entries.
  • Unconditional portability (*):
    • the C code has "only" been widely ported, with specific source parts (via conditional compilation) for different OS and compilers;
    • a single Ada source code set produces a native Zip/UnZip in machine code for every OS, with every Ada compiler - no "header hell", nothing to configure (sceptic ? click here to see a list of reportedly successfully tested environments).
  • No effort of interfacing: interfacing is a frequent source of maintenance troubles, compatibility issues and portability constraints.
    With Zip-Ada, it is possible to have full-Ada projects using Zip archives, all compiled by a single compiler.
  • Transparency: full sources are visible; it is easier to verify and customize.
  • Benefit from the powerful LZMA and BZip2 compression formats, which are not available in zlib and zlib-based Zip tools (they are limited to the weaker Deflate format).
    Additionally, Zip-Ada provides the Preselection algorithm-picking method for compressing data depending on their type and size.
  • Zip-Ada can use an archive as a read-only file system. Since the archive itself can be stored in memory, Zip-Ada can even work as a RAM-disk.
(*) within limits of compiler's provided integer types and target architecture capacity.

Distribution

Zip-Ada is free software under MIT license - see copyright notice in the file zip.ads.

Download

  Download the library from the SourceForge project page.  

You can also...
  • get the corresponding crate on Alire; for details, click here:  Alire Crate
  • check the mirror on GitHub.

The zipada*.zip archive contains:
  • The full library Ada sources inside one directory, Zip_Lib.
  • Within the Zip_Lib library:
    • a standalone generic streaming LZ77 encoder (can be used outside of the Zip context)
    • standalone generic streaming LZMA encoder and decoder (can be used outside of the Zip context).
  • Some command-line demos, and the following tools:
    • ZipAda, a tool that creates a compressed Zip archive.
    • UnZipAda, a tool that extracts some or all files from a Zip archive.
    • Comp_Zip, an utility for comparing two Zip archives (compare contents, check missing files).
    • Find_Zip, an utility for searching a text string across contents of a Zip archive.
    • ReZip, a tool for recompressing Zip archives towards optimal compression.
    • bunzip, a tool that decompresses BZip2 compressed files (.bz2).
    • lzma_enc and lzma_dec, a tool that encodes/decodes LZMA compressed files (.lzma).

Screenshots:

Zip-Ada in action
within a Zip archive
manager (AZip):

Zip-Ada in action
within a self-extracting
installer:
HTML report
from the ReZip tool:
AZip   Installer   ReZip report  

Presentations:

Zip-Ada @ FOSDEM 2019:
 
Zip-Ada @ Swiss Ada Event 2017:
Zip-Ada @ FOSDEM 2019   Zip-Ada @ Swiss Ada Event 2017 (part 1)   Zip-Ada @ Swiss Ada Event 2017 (part 1)  

A small demo's source:

--  Zip archive creation demo.
--  For a complete Zip creation tool, see tools/zipada.adb .
--
with Zip.Create;

procedure Demo_Zip is
  use Zip.Create;
  zip_file : aliased Zip_File_Stream;  --  Archive is a file in this example.
  archive : Zip_Create_Info;
begin
  Create_Archive (archive, zip_file'Unchecked_Access, "mini_zip.zip");
  --  We insert a couple of files into the Zip archive:
  Add_File (archive, "demo/demo_zip.adb", Password => "1234");
  Add_File (archive, "demo/demo_unzip.adb");
  --  Here we add directly some contents to the Zip archive
  --  without a file in the first place:
  Add_String
    (archive,
     "==== Hello world! ====" & ASCII.LF &
     "It is such a nice ""Hello world""-like demo, isn't it ?",
     "nice_string.txt");
  Add_Empty_Folder (archive, "empty_folder/");
  Finish (archive);
end Demo_Zip;

For viewing more sources...

Browse the source (of version 58)  

Source web pages automatically generated by gnathtml (GNAT).

Present state - latest changes - history

For the full history, click here.

Contact:

Mail:     Gautier de Montmollin, e-mail
For a little sponsoring (e.g. the equivalent of a glass of wine)...   Support This Project

An article about fuzzing (testing with randomized input data) and Zip-Ada:

Technical documentation: read PKWare's appnote.txt (included in the Zip-Ada archive).

On Gautier's blog: some news about Zip-Ada and other Ada projects.


Combinations (Operating System, processor, compiler) where the Zip-Ada library - one single source, zero conditional compilation - is reported to be in use:

OSCPUCompiler
OpenVMSIntel Itanium (64 bit) GNU - GNAT
AIXPower7 (64 bit)
MS Windows 32-bitIntel x86
MS Windows 64-bitAMD/Intel x64
Linux 32-bitIntel x86
Linux 64-bitAMD/Intel x64
Linux on PS3Cell (64 bit)
Linux on Raspberry PiARM
Mac OS XPowerPC (64 bit)
Mac OS XAMD/Intel x64 (64 bit)
SolarisSPARC (32 or 64 bit)
SolarisAMD/Intel x64 (64 bit)
OpenBSD(one of several)
FreeBSDIntel x86 (32 bit)
FreeBSDAMD/Intel x64 (64 bit)
Android 2.3+ARM
MS Windows x64AMD/Intel x64 (64 bit)PTC - ObjectAda
MS Windows NT+Intel x86 (32 bit)SofCheck - AdaMagic
MS Windows NT+AMD/Intel x64 (64 bit)
LinuxIntel x86 (32 bit)
Mac OS XPowerPC (64 bit)
Mac OS XAMD/Intel x64 (64 bit)
SolarisSPARC (32 or 64 bit)
SolarisAMD/Intel x64

Don't hesitate to tell me about other OS / CPU / compiler combinations!
Summary of supported Zip internal compression formats (each compressed file in a Zip archive can have a different compression format):



  
Zip-Ada   
Other software… Info-Zip
Format Format #
Compress Decompress
PKZip WinZip UnZip Zip
store 0
v.22 v.4




shrink 1
v.22 v.4




reduce 1..4 2..5
v.29 v.4




implode 6

v.4




deflate 8
v.50
(v.40-49: limited)
v.4
v.2.0


v.2.0
enhanced deflate 9

v.30
v.2.1 v.9.0 v.5.5
bzip2 12

v.36

v.4.6 v.10.0 v.6.0 v.3.0
lzma 14
v.51 v.47
v.6.3 v.12.0

ppmd 98



v.6.3 v.10.0



Some Zip-Ada users:
Here is a list of other open-source projects I participate to on SourceForge. Click on the links below for details.
Some projects have GitHub mirrors too.

Some Ada compilers:
External compression tools used by ReZip:
Powered by Ada          Awesome Ada