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.
- type Zip = Ptr C'zip
- type ZipFile = Ptr C'zip_file
- data OpenFlag
- = CreateFlag
- | ExclFlag
- | CheckConsFlag
- data FileFlag
- data ZipError
- = ErrOK
- | ErrMULTIDISK
- | ErrRENAME
- | ErrCLOSE
- | ErrSEEK
- | ErrREAD
- | ErrWRITE
- | ErrCRC
- | ErrZIPCLOSED
- | ErrNOENT
- | ErrEXISTS
- | ErrOPEN
- | ErrTMPOPEN
- | ErrZLIB
- | ErrMEMORY
- | ErrCHANGED
- | ErrCOMPNOTSUPP
- | ErrEOF
- | ErrINVAL
- | ErrNOZIP
- | ErrINTERNAL
- | ErrINCONS
- | ErrREMOVE
- | ErrDELETED
- data Word8
- withZip :: String -> [OpenFlag] -> (Zip -> IO a) -> IO a
- getFiles :: Zip -> [FileFlag] -> IO [String]
- getFileSize :: Zip -> String -> [FileFlag] -> IO Int
- readZipFile :: Zip -> String -> [FileFlag] -> IO ByteString
- readZipFile' :: Zip -> String -> [FileFlag] -> IO [Word8]
- readZipFileHead :: Zip -> String -> [FileFlag] -> Int -> IO ByteString
- readZipFileHead' :: Zip -> String -> [FileFlag] -> Int -> IO [Word8]
- open :: String -> [OpenFlag] -> IO Zip
- close :: Zip -> IO ()
- get_num_files :: Zip -> IO Int
- get_name :: Zip -> Int -> [FileFlag] -> IO String
- fopen :: Zip -> String -> [FileFlag] -> IO ZipFile
- fopen_index :: Zip -> Int -> [FileFlag] -> IO ZipFile
- fclose :: ZipFile -> IO ()
- fread :: ZipFile -> Int -> IO [Word8]
- catchZipError :: IO a -> (ZipError -> IO a) -> IO a
- isFile :: String -> Bool
- isDir :: String -> Bool
Types
type ZipFile = Ptr C'zip_fileSource
Handler of an open file in the zip archive.
Flags for opening an archive.
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. |
Flags for accessing files in the archive.
Please consult libzip
documentation about their use.
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. |
libzip
error codes.
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. |
data Word8
8-bit unsigned integer type
High-level interface
:: 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.
Get size of the file in archive.
:: 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.
:: 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
.
:: 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.
:: 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 zip archive specified by path and return its handler on success.
get_num_files :: Zip -> IO IntSource
Return the number of files in the archive.
fopen_index :: Zip -> Int -> [FileFlag] -> IO ZipFileSource
Open n-th file in zip archive for reading.