zip-0.1.0: Operations on zip archives

Copyright© 2016 Mark Karpov
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov@openmailbox.org>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Codec.Archive.Zip.Type

Contents

Description

Types used by the package. You don't usually need to import this module, because Codec.Archive.Zip re-exports everything you may need, import that module instead.

Synopsis

Entry selector

data EntrySelector Source

This data type serves for naming and selection of archive entries. It can be created only with help of smart constructor mkEntrySelector, and it's the only “key” that can be used to select files in archive or to name new files.

The abstraction is crucial for ensuring that created archives are portable across operating systems, file systems, and different platforms. Since on some operating systems, file paths are case-insensitive, this selector is also case-insensitive. It makes sure that only relative paths are used to name files inside archive, as it's recommended in the specification. It also guarantees that forward slashes are used when the path is stored inside archive for compatibility with Unix-like operating systems (as it is recommended in the specification). On the other hand, in can be rendered as ordinary relative file path in OS-specific format, when needed.

mkEntrySelector :: MonadThrow m => Path Rel File -> m EntrySelector Source

Create EntrySelector from Path Rel File. To avoid problems with distribution of the archive, characters that some operating systems do not expect in paths are not allowed. Proper paths should pass these checks:

  • isValid
  • isValid
  • binary representation of normalized path should be not longer than 65535 bytes

This function can throw EntrySelectorException exception.

unEntrySelector :: EntrySelector -> Path Rel File Source

Make a relative path from EntrySelector. Every EntrySelector produces single Path Rel File that corresponds to it.

getEntryName :: EntrySelector -> Text Source

Get entry name given EntrySelector in from that is suitable for writing to file header.

data EntrySelectorException Source

Exception describing various troubles you can have with EntrySelector.

Constructors

InvalidEntrySelector (Path Rel File)

Selector cannot be created from this path

Entry description

data EntryDescription Source

This record represents all information about archive entry that can be stored in a .ZIP archive. It does not mirror local file header or central directory file header, but their binary representation can be built given this date structure and actual archive contents.

Constructors

EntryDescription 

Fields

edVersionMadeBy :: Version

Version made by

edVersionNeeded :: Version

Version needed to extract

edCompression :: CompressionMethod

Compression method

edModTime :: UTCTime

Last modification date and time

edCRC32 :: Word32

CRC32 check sum

edCompressedSize :: Natural

Size of compressed entry

edUncompressedSize :: Natural

Size of uncompressed entry

edOffset :: Natural

Absolute offset of local file header

edComment :: Maybe Text

Entry comment

edExtraField :: Map Word16 ByteString

All extra fields found

data CompressionMethod Source

Supported compression methods.

Constructors

Store

Store file uncompressed

Deflate

Deflate

BZip2

Compressed using BZip2 algorithm

Archive desrciption

data ArchiveDescription Source

Information about archive as a whole.

Constructors

ArchiveDescription 

Fields

adComment :: Maybe Text

Comment of entire archive

adCDOffset :: Natural

Absolute offset of start of central directory

adCDSize :: Natural

Size of central directory record

Exceptions

data ZipException Source

Bad things that can happen when you use the library.

Constructors

EntryDoesNotExist (Path Abs File) EntrySelector

Thrown when you try to get contents of non-existing entry

ParsingFailed (Path Abs File) String

Thrown when archive structure cannot be parsed