LibZip-0.2.0.3: Bindings to libzip, a library for manipulating zip archives.

Codec.Archive.LibZip.LegacyZeroZero

Contents

Description

This module is a backwards compatible replacement for Codec.Archive.LibZip module of LibZip 0.0.x. This API is deprecated, please don't use it in new code.

Synopsis

Types

type Zip = Ptr C'zipSource

Handler of the open zip file.

type ZipFile = Ptr C'zip_fileSource

Handler of an open file in the zip archive.

data OpenFlag Source

Flags for opening an archive.

Constructors

CreateFlag

Create an archive if it does not exist.

ExclFlag

Error if the archive already exists.

CheckConsFlag

Check archive's consistency and error on failure.

data FileFlag Source

Flags for accessing files in the archive. Please consult libzip documentation about their use.

Constructors

FileNOCASE

Ignore case on name lookup.

FileNODIR

Ignore directory component.

FileCOMPRESSED

Read the compressed data.

FileUNCHANGED

Read the original data, ignore changes.

FileRECOMPRESS

Force recompression of data.

data ZipError Source

libzip error codes.

Constructors

ErrOK

No error.

ErrMULTIDISK

Multi-disk zip archives not supported.

ErrRENAME

Renaming temporary file failed.

ErrCLOSE

Closing zip archive failed.

ErrSEEK

Seek error.

ErrREAD

Read error.

ErrWRITE

Write error.

ErrCRC

CRC error.

ErrZIPCLOSED

Containing zip archive was closed.

ErrNOENT

No such file.

ErrEXISTS

File already exists.

ErrOPEN

Can't open file.

ErrTMPOPEN

Failure to create temporary file.

ErrZLIB

Zlib error.

ErrMEMORY

Malloc error.

ErrCHANGED

Entry has been changed.

ErrCOMPNOTSUPP

Compression method not supported.

ErrEOF

Premature EOF.

ErrINVAL

Invalid argument.

ErrNOZIP

Not a zip archive.

ErrINTERNAL

Internal error.

ErrINCONS

Zip archive inconsistent.

ErrREMOVE

Can't remove file.

ErrDELETED

Entry has been deleted.

High-level interface

withZipSource

Arguments

:: String

path of the file to open

-> [OpenFlag]

open mode

-> (Zip -> IO a)

action to do on zip arhive

-> IO a 

Open zip archive, do something, and close the archive.

getFiles :: Zip -> [FileFlag] -> IO [String]Source

Get names of the files in archive.

getFileSizeSource

Arguments

:: Zip

zip archive

-> String

name of the file in the archive

-> [FileFlag]

file name mode

-> IO Int 

Get size of the file in archive.

readZipFileSource

Arguments

:: Zip

zip archive

-> String

name of the file in the archive

-> [FileFlag]

file name mode

-> IO ByteString 

Read uncompressed file from the archive. Produce a strict ByteString.

readZipFile'Source

Arguments

:: Zip

zip archive

-> String

name of the file in the archive

-> [FileFlag]

file name mode

-> IO [Word8] 

Read uncompressed file from the archive. Produce a list of Word8.

readZipFileHeadSource

Arguments

:: Zip

zip archive

-> String

name of the file in the archive

-> [FileFlag]

file name mode

-> Int

how many bytes to read

-> IO ByteString 

Read beginning of the uncompressed file from the archive. Produce a strict ByteString.

readZipFileHead'Source

Arguments

:: Zip

zip archive

-> String

name of the file in the archive

-> [FileFlag]

file name mode

-> Int

how many bytes to read

-> IO [Word8] 

Read beginning of the uncompressed file from the archive. Produce a list of Word8.

Low-level bindings

openSource

Arguments

:: String

path of the file to open

-> [OpenFlag]

open mode

-> IO Zip

handler of the open zip archive

Open zip archive specified by path and return its handler on success.

close :: Zip -> IO ()Source

Close zip archive.

get_num_files :: Zip -> IO IntSource

Return the number of files in the archive.

get_name :: Zip -> Int -> [FileFlag] -> IO StringSource

Get name of file by index.

fopen :: Zip -> String -> [FileFlag] -> IO ZipFileSource

Open file in zip archive for reading.

fopen_index :: Zip -> Int -> [FileFlag] -> IO ZipFileSource

Open n-th file in zip archive for reading.

fclose :: ZipFile -> IO ()Source

Close file in zip archive.

fread :: ZipFile -> Int -> IO [Word8]Source

Read from file in zip archive.

Utilities

catchZipError :: IO a -> (ZipError -> IO a) -> IO aSource

Wrapper to catch library errors.

isFile :: String -> BoolSource

Return True if path is a file name, not a directory name (does not end with /).

isDir :: String -> BoolSource

Return True if path is a directory name (ends with /).