zip-archive-0.3.2: Library for creating and modifying zip archives.

CopyrightJohn MacFarlane
LicenseBSD3
MaintainerJohn MacFarlane < jgm at berkeley dot edu >
Stabilityunstable
Portabilityso far only tested on GHC
Safe HaskellNone
LanguageHaskell98

Codec.Archive.Zip

Contents

Description

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 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.

As an example of the use of the library, a standalone zip archiver and extracter, 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

Synopsis

Data structures

data Archive Source #

Structured representation of a zip archive, including directory information and contents (in lazy bytestrings).

Constructors

Archive 

Fields

data Entry Source #

Representation of an archived file, including content and metadata.

Constructors

Entry 

Fields

data ZipOption Source #

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

OptPreserveSymbolicLinks

Preserve symbolic links as such. This option is ignored on Windows.

data ZipException Source #

Constructors

CRC32Mismatch FilePath 

Instances

Data ZipException Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ZipException -> c ZipException #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ZipException #

toConstr :: ZipException -> Constr #

dataTypeOf :: ZipException -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ZipException) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ZipException) #

gmapT :: (forall b. Data b => b -> b) -> ZipException -> ZipException #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ZipException -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ZipException -> r #

gmapQ :: (forall d. Data d => d -> u) -> ZipException -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ZipException -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ZipException -> m ZipException #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipException -> m ZipException #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipException -> m ZipException #

Show ZipException Source # 
Exception ZipException Source # 

emptyArchive :: Archive Source #

A zip archive with no contents.

Pure functions for working with zip archives

toArchive :: ByteString -> Archive Source #

Reads an Archive structure from a raw zip archive (in a lazy bytestring).

toArchiveOrFail :: ByteString -> Either String Archive Source #

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.

fromArchive :: Archive -> ByteString Source #

Writes an Archive structure to a raw zip archive (in a lazy bytestring).

filesInArchive :: Archive -> [FilePath] Source #

Returns a list of files in a zip archive.

addEntryToArchive :: Entry -> Archive -> Archive Source #

Adds an entry to a zip archive, or updates an existing entry.

deleteEntryFromArchive :: FilePath -> Archive -> Archive Source #

Deletes an entry from a zip archive.

findEntryByPath :: FilePath -> Archive -> Maybe Entry Source #

Returns Just the zip entry with the specified path, or Nothing.

fromEntry :: Entry -> ByteString Source #

Returns uncompressed contents of zip entry.

toEntry Source #

Arguments

:: FilePath

File path for entry

-> Integer

Modification time for entry (seconds since unix epoch)

-> ByteString

Contents of entry

-> Entry 

Create an Entry with specified file path, modification time, and contents.

IO functions for working with zip archives

readEntry :: [ZipOption] -> FilePath -> IO Entry Source #

Generates a Entry from a file or directory.

writeEntry :: [ZipOption] -> Entry -> IO () Source #

Writes contents of an Entry to a file. Throws a CRC32Mismatch exception if the CRC32 checksum for the entry does not match the uncompressed data.

addFilesToArchive :: [ZipOption] -> Archive -> [FilePath] -> IO Archive Source #

Add the specified files to an Archive. If OptRecursive is specified, recursively add files contained in directories. if OptPreserveSymbolicLinks is specified, don't recurse into it. If OptVerbose is specified, print messages to stderr.

extractFilesFromArchive :: [ZipOption] -> Archive -> IO () Source #

Extract all files from an Archive, creating directories as needed. If OptVerbose is specified, print messages to stderr. Note that the last-modified time is set correctly only in POSIX, not in Windows.