zip-stream-0.2.2.0: ZIP archive streaming using conduits

Safe Haskell | None
Language | Haskell2010

Codec.Archive.Zip.Conduit.UnZip

Description

Stream the extraction of a zip file, e.g., as it's being downloaded.

Synopsis

- unZipStream :: forall (m :: Type -> Type). (MonadThrow m, PrimMonad m) => ConduitM ByteString (Either ZipEntry ByteString) m ZipInfo
- data ZipEntry = ZipEntry {
  - zipEntryName :: Either Text ByteString
  - zipEntryTime :: LocalTime
  - zipEntrySize :: Maybe Word64
  - zipEntryExternalAttributes :: Maybe Word32
  }
- data ZipInfo = ZipInfo {
  - zipComment :: ByteString
  }

# Documentation

unZipStream :: forall (m :: Type -> Type). (MonadThrow m, PrimMonad m) => ConduitM ByteString (Either ZipEntry ByteString) m ZipInfo Source #

Stream process a zip file, producing a sequence of entry headers and data blocks. For example, this might produce: `Left (ZipEntry "directory/" ...), Left (ZipEntry "directory/file.txt" ...), Right "hello w", Right "orld!\n", Left ...` The final result is summary information taken from the end of the zip file. No state is maintained during processing, and, in particular, any information in the central directory is discarded.

This only supports a limited number of zip file features, including deflate compression and zip64. It does not (ironically) support uncompressed zip files that have been created as streams, where file sizes are not known beforehand. Since it does not use the offset information at the end of the file, it assumes all entries are packed sequentially, which is usually the case. Any errors are thrown in the underlying monad (as `ZipError`s or `ParseError`).

data ZipEntry Source #

(The beginning of) a single entry in a zip stream, which may be any file or directory. As per zip file conventions, directory names should end with a slash and have no data, but this library does not ensure that.

Constructors

ZipEntry |

Fields

- zipEntryName :: Either Text ByteString

  File name (in posix format, no leading slashes), either UTF-8 encoded text or raw bytes (CP437), with a trailing slash for directories

- zipEntryTime :: LocalTime

  Modification time

- zipEntrySize :: Maybe Word64

  Size of file data (if known); checked on zipping and also used as hint to enable zip64. Disables compression for known 0-byte files.

- zipEntryExternalAttributes :: Maybe Word32

  Host-dependent attributes, often MS-DOS directory attribute byte (only supported when zipping)

#### Instances

Instances details

Show ZipEntry Source # |
Instance details Defined in Codec.Archive.Zip.Conduit.Types Methods showsPrec :: Int -> ZipEntry -> ShowS Source # show :: ZipEntry -> String Source # showList :: [ZipEntry] -> ShowS Source #
Eq ZipEntry Source # |
Instance details Defined in Codec.Archive.Zip.Conduit.Types Methods (==) :: ZipEntry -> ZipEntry -> Bool Source # (/=) :: ZipEntry -> ZipEntry -> Bool Source #

data ZipInfo Source #

Summary information at the end of a zip stream.

Constructors

ZipInfo |

Fields

- zipComment :: ByteString

#### Instances

Instances details

Show ZipInfo Source # |
Instance details Defined in Codec.Archive.Zip.Conduit.Types Methods showsPrec :: Int -> ZipInfo -> ShowS Source # show :: ZipInfo -> String Source # showList :: [ZipInfo] -> ShowS Source #
Eq ZipInfo Source # |
Instance details Defined in Codec.Archive.Zip.Conduit.Types Methods (==) :: ZipInfo -> ZipInfo -> Bool Source # (/=) :: ZipInfo -> ZipInfo -> Bool Source #