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

Safe HaskellSafe-Infered

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'zip

Handler of the open zip file.

type ZipFile = Ptr C'zip_file

Handler of an open file in the zip archive.

data OpenFlag

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

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

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

withZip

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]

Get names of the files in archive.

getFileSize

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.

readZipFile

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'

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.

readZipFileHead

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'

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

open

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 ()

Close zip archive.

get_num_files :: Zip -> IO Int

Return the number of files in the archive.

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

Get name of file by index.

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

Open file in zip archive for reading.

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

Open n-th file in zip archive for reading.

fclose :: ZipFile -> IO ()

Close file in zip archive.

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

Read from file in zip archive.

Utilities

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

Wrapper to catch library errors.

isFile :: String -> Bool

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

isDir :: String -> Bool

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