LibZip for Haskell
This is home page of Haskell bindings for an excellent libzip library. Haskell bindings cover all (or almost all) the functionality of the corresponding C library: creating, reading, updating and deleting files, editing metadata (archive and file comments). LibZip is particularly suitable for processing large on-disk zip archives.
API documentation is available on Hackage.
There is also an example of
zip utility written with LibZip. It should give an idea how to use the library.
To install LibZip run:
cabal update cabal install LibZip
To install from source, first go to
bindings-libzip/ folder and
cabal install, then do the same in
If you do not have
pkg-config installed (e.g. on a Windows machine), you may install the library without it, if you use
-fNoPkgConfig flag for
cabal configure and
Make sure you have
libzip header files installed on your system. Current LibZip is buildable with GHC 7.10 and
cabal-install utility. Probably it is still buildable with older GHC versions.
Why another zip library?
In my another project I need to read large zip archives (up to 2 GB) and index their contents. I found there is already zip-archive library on Hackage. It is nice and pure (working with lazy bytestrings, not files), but it doesn't suit my needs for two reasons:
zip-archivelibrary is GPL,
zip-archivereads the whole archive into memory even on the most routine operations (like getting a list of files in the archive).
The fundamental problem with
zip-archive is that bytestrings are sequential and don't have
fseek. There is no reliable way to implement random access.
And as I want to release my Haskell code under BSD or MIT licenses, GPL library had to be avoided.
So I decided to rely on a well-tested C-library with predictable performance to do the hard work, and wrap it with a nice Haskell interface to avoid boring resource management. This is how LibZip was born.
Yes, it's here. Get your own copy:
hg clone http://bitbucket.org/astanin/hs-libzip/
or browse online.
Does anything go wrong with LibZip? It shouldn't.
See also test coverage.
Current version is 1.0.1 and it is compatible with libzip-1.0.x, but doesn't implement all its features yet. Version 0.11.1 is compatible with libzip-0.11.*. Earlier version (0.10.2) is compatible with libzip-0.10.*.
- LibZip 1.0.1. Compatible with libzip-1.0.1. Buildable with GHC 7.10.1.
- LibZip 0.11.1. Bug-fix release. Added a missing test file on Hackage.
- LibZip 0.11, bindings-libzip 0.11. Compatible with libzip-0.11. API changes to support Zip64 (large files), UTF-8 in file names in comments, file encryption and compression methods.
- LibZip 0.10.2, bindings-libzip 0.10.2. Compatible with GHC 7.6.1.
- LibZip 0.10.1, bindings-libzip 0.10.1. Compatible with minor revisions of libzip-0.10.*
- LibZip 0.10, bindings-libzip 0.10. Compatibility with
libzip-0.10. API change. 86380ecbc8d9
- LibZip 0.2.0.4, bindings-libzip 0.1.0.4. Allow build on GHC-7.4.1.
- LibZip 0.2.0.3, bindings-libzip 0.1.0.3. Removed datatype contexts. GHC-7.2.1 is supported.
- bindings-libzip 0.1.0.2. Optional
- LibZip 0.2.0.1, bindings-libzip 0.1.0.1. Updated
basedependency for GHC-7.0.1.
- 0.2. Low-level bindings moved to a separate package
- 0.1. Bindings re-imlpemented with bindings-DSL. New high-level monadic API. Legacy API is still available. Complete CRUD support.
- 0.0.1 and 0.0.2. Partial bindings implemented with C2Hs. Read-only access to Zip archives.