HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulezip-archive-0.5Haskell2010

Codec.Archive.Zip

The zip-archive library provides functions for creating, modifying, and extracting files from zip archives.

Certain simplifying assumptions are made about the zip archives: in particular, there is no support for strong encryption, zip files that span multiple disks, ZIP64, OS-specific file attributes, or compression methods other than Deflate. However, the library should be able to read the most common zip archives, and the archives it produces should be readable by all standard unzip programs.

One known limitation: when parsing an archive whose local file headers defer sizes to a data descriptor (general purpose bit 3) and whose entries are stored without compression, the end of the entry data can only be found by scanning for the optional data descriptor signature 0x08074b50. Parsing such an archive can therefore fail (or truncate an entry) if that byte sequence occurs within the stored data itself. Archives of this kind are rare; deflated entries with data descriptors are not affected.

As an example of the use of the library, a standalone zip archiver and extractor, Zip.hs, is provided in the source distribution.

For more information on the format of zip archives, consult http://www.pkware.com/documents/casestudies/APPNOTE.TXT

  • 6 types
  • 20 values
  • Packagezip-archive-0.5
  • Exports26
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceZip.hs

Data structures

7 declarations
datadata Entry
#

Representation of an archived file, including content and metadata.

Constructors

Instances3Eq, Read, Show
  • Eq EntryDefined in zip-archive-0.5 · Codec.Archive.Zip
  • Read EntryDefined in zip-archive-0.5 · Codec.Archive.Zip
  • Show EntryDefined in zip-archive-0.5 · Codec.Archive.Zip
datadata ZipOption
#

Constructors

  • OptRecursive

    Recurse into directories when adding files

  • OptVerbose

    Print information to stderr

  • OptDestination FilePath

    Directory in which to extract

  • OptLocation FilePath !Bool

    Where to place file when adding files and whether to append current path

Instances3Eq, Read, Show
datadata ZipException
#

Constructors

Instances4Eq, Data, Show, Exception

Pure functions for working with zip archives

14 declarations

Like toArchive, but returns an Either value instead of raising an error if the archive cannot be decoded. NOTE: This function only works properly when the library is compiled against binary >= 0.7. With earlier versions, it will always return a Right value, raising an error if parsing fails.

Writes an Archive structure to a raw zip archive (in a lazy bytestring). Throws a pure Zip64NotSupported exception if the archive has 65535 or more entries or is 4GB or larger, since this would require the (unsupported) ZIP64 extension.

valuetoEntry
  1. :: FilePath

    File path for entry

  2. -> Integer

    Modification time for entry (seconds since unix epoch)

  3. -> ByteString

    Contents of entry

  4. -> Entry
#

Create an Entry with specified file path, modification time, and contents. Throws a pure Zip64NotSupported exception if the contents are too large to be represented without the (unsupported) ZIP64 extension.

IO functions for working with zip archives

5 declarations