-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Operations on zip archives
--   
--   Operations on zip archives.
@package zip
@version 2.2.1

-- | Support for decoding of CP 437 text.
module Codec.Archive.Zip.CP437

-- | Decode a ByteString containing CP 437 encoded text.
decodeCP437 :: ByteString -> Text

-- | Types used by the package.
module Codec.Archive.Zip.Internal.Type

-- | This data type serves for naming and selection of archive entries. It
--   can be created only with the help of the smart constructor
--   mkEntrySelector, and it's the only “key” that can be used to
--   refer to files in the archive or to name new archive entries.
--   
--   The abstraction is crucial for ensuring that created archives are
--   portable across operating systems, file systems, and 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 the archive for compatibility with
--   Unix-like operating systems (as recommended in the specification). On
--   the other hand, in can be rendered as an ordinary relative file path
--   in OS-specific format when needed.
data EntrySelector

-- | Create an EntrySelector from a FilePath. To avoid
--   problems with distribution of the archive, characters that some
--   operating systems do not expect in paths are not allowed.
--   
--   Argument to mkEntrySelector should pass these checks:
--   
--   
--   
- isValid
--   
- isValid
--   
- it is a relative path without slash at the end
--   
- binary representations of normalized path should be not longer
--   than 65535 bytes
--   
--   
--   This function can throw an EntrySelectorException.
mkEntrySelector :: MonadThrow m => FilePath -> m EntrySelector

-- | Restore a relative path from EntrySelector. Every
--   EntrySelector corresponds to a FilePath.
unEntrySelector :: EntrySelector -> FilePath

-- | Get an entry name in the from that is suitable for writing to file
--   header, given an EntrySelector.
getEntryName :: EntrySelector -> Text

-- | The problems you can have with an EntrySelector.
newtype EntrySelectorException

-- | EntrySelector cannot be created from this path
InvalidEntrySelector :: FilePath -> EntrySelectorException

-- | The 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 representations can be built given this
--   data structure and the archive contents.
data EntryDescription
EntryDescription :: Version -> Version -> CompressionMethod -> UTCTime -> Word32 -> Natural -> Natural -> Natural -> Maybe Text -> Map Word16 ByteString -> Word32 -> EntryDescription

-- | Version made by
[edVersionMadeBy] :: EntryDescription -> Version

-- | Version needed to extract
[edVersionNeeded] :: EntryDescription -> Version

-- | Compression method
[edCompression] :: EntryDescription -> CompressionMethod

-- | Last modification date and time
[edModTime] :: EntryDescription -> UTCTime

-- | CRC32 check sum
[edCRC32] :: EntryDescription -> Word32

-- | Size of compressed entry
[edCompressedSize] :: EntryDescription -> Natural

-- | Size of uncompressed entry
[edUncompressedSize] :: EntryDescription -> Natural

-- | Absolute offset of local file header
[edOffset] :: EntryDescription -> Natural

-- | Entry comment
[edComment] :: EntryDescription -> Maybe Text

-- | All extra fields found
[edExtraField] :: EntryDescription -> Map Word16 ByteString

-- | External file attributes
[edExternalFileAttrs] :: EntryDescription -> Word32

-- | The supported compression methods.
data CompressionMethod

-- | Store file uncompressed
Store :: CompressionMethod

-- | Deflate
Deflate :: CompressionMethod

-- | Compressed using BZip2 algorithm
BZip2 :: CompressionMethod

-- | Compressed using Zstandard algorithm
Zstd :: CompressionMethod

-- | The information about the archive as a whole.
data ArchiveDescription
ArchiveDescription :: Maybe Text -> Natural -> Natural -> ArchiveDescription

-- | The comment of the entire archive
[adComment] :: ArchiveDescription -> Maybe Text

-- | Absolute offset of the start of central directory
[adCDOffset] :: ArchiveDescription -> Natural

-- | The size of central directory record
[adCDSize] :: ArchiveDescription -> Natural

-- | The bad things that can happen when you use the library.
data ZipException

-- | Thrown when you try to get contents of non-existing entry
EntryDoesNotExist :: FilePath -> EntrySelector -> ZipException

-- | Thrown when attempting to decompress an entry compressed with an
--   unsupported compression method or the library is compiled without
--   support for it.
UnsupportedCompressionMethod :: CompressionMethod -> ZipException

-- | Thrown when archive structure cannot be parsed.
ParsingFailed :: FilePath -> String -> ZipException
instance GHC.Internal.Enum.Bounded Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Internal.Data.Data.Data Codec.Archive.Zip.Internal.Type.ArchiveDescription
instance GHC.Internal.Data.Data.Data Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Internal.Enum.Enum Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.Type.ArchiveDescription
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.Type.EntryDescription
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.Type.EntrySelector
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.Type.EntrySelectorException
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.Type.ZipException
instance GHC.Internal.Exception.Type.Exception Codec.Archive.Zip.Internal.Type.EntrySelectorException
instance GHC.Internal.Exception.Type.Exception Codec.Archive.Zip.Internal.Type.ZipException
instance GHC.Classes.Ord Codec.Archive.Zip.Internal.Type.ArchiveDescription
instance GHC.Classes.Ord Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Classes.Ord Codec.Archive.Zip.Internal.Type.EntrySelector
instance GHC.Classes.Ord Codec.Archive.Zip.Internal.Type.EntrySelectorException
instance GHC.Classes.Ord Codec.Archive.Zip.Internal.Type.ZipException
instance GHC.Internal.Read.Read Codec.Archive.Zip.Internal.Type.ArchiveDescription
instance GHC.Internal.Read.Read Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Internal.Show.Show Codec.Archive.Zip.Internal.Type.ArchiveDescription
instance GHC.Internal.Show.Show Codec.Archive.Zip.Internal.Type.CompressionMethod
instance GHC.Internal.Show.Show Codec.Archive.Zip.Internal.Type.EntryDescription
instance GHC.Internal.Show.Show Codec.Archive.Zip.Internal.Type.EntrySelector
instance GHC.Internal.Show.Show Codec.Archive.Zip.Internal.Type.EntrySelectorException
instance GHC.Internal.Show.Show Codec.Archive.Zip.Internal.Type.ZipException

-- | Unix-specific functionality of zip archives.
module Codec.Archive.Zip.Unix

-- | Convert external attributes to the file info.
--   
--   
--   >>> toFileMode 2179792896
--   0o0755
--   
toFileMode :: Word32 -> CMode

-- | Convert external attributes to the file info. The function assumes a
--   regular file and keeps DOS attributes untouched.
--   
--   
--   >>> fromFileMode 0o0755
--   2179792896
--   
fromFileMode :: CMode -> Word32

-- | Low-level, non-public types and operations.
module Codec.Archive.Zip.Internal

-- | The sum type describes all possible actions that can be performed on
--   an archive.
data PendingAction

-- | Add an entry given its Source
SinkEntry :: CompressionMethod -> ConduitT () ByteString (ResourceT IO) () -> EntrySelector -> PendingAction

-- | Add an entry given its content as a string ByteString.
StrictEntry :: CompressionMethod -> ByteString -> EntrySelector -> PendingAction

-- | Copy an entry from another archive without re-compression
CopyEntry :: FilePath -> EntrySelector -> EntrySelector -> PendingAction

-- | Change the name of the entry inside archive
RenameEntry :: EntrySelector -> EntrySelector -> PendingAction

-- | Delete an entry from archive
DeleteEntry :: EntrySelector -> PendingAction

-- | Change the compression method on an entry
Recompress :: CompressionMethod -> EntrySelector -> PendingAction

-- | Set the comment for a particular entry
SetEntryComment :: Text -> EntrySelector -> PendingAction

-- | Delete theh comment of a particular entry
DeleteEntryComment :: EntrySelector -> PendingAction

-- | Set the modification time of a particular entry
SetModTime :: UTCTime -> EntrySelector -> PendingAction

-- | Add an extra field to the specified entry
AddExtraField :: Word16 -> ByteString -> EntrySelector -> PendingAction

-- | Delete an extra filed of the specified entry
DeleteExtraField :: Word16 -> EntrySelector -> PendingAction

-- | Set the comment for the entire archive
SetArchiveComment :: Text -> PendingAction

-- | Delete the comment of the entire archive
DeleteArchiveComment :: PendingAction

-- | Set an external file attribute for the specified entry
SetExternalFileAttributes :: Word32 -> EntrySelector -> PendingAction

-- | A collection of maps describing how to produce entries in the
--   resulting archive.
data ProducingActions
ProducingActions :: Map FilePath (Map EntrySelector EntrySelector) -> Map EntrySelector (EntryOrigin, ConduitT () ByteString (ResourceT IO) ()) -> ProducingActions
[paCopyEntry] :: ProducingActions -> Map FilePath (Map EntrySelector EntrySelector)
[paSinkEntry] :: ProducingActions -> Map EntrySelector (EntryOrigin, ConduitT () ByteString (ResourceT IO) ())

-- | A collection of editing actions, that is, actions that modify already
--   existing entries.
data EditingActions
EditingActions :: Map EntrySelector CompressionMethod -> Map EntrySelector Text -> Map EntrySelector () -> Map EntrySelector UTCTime -> Map EntrySelector (Map Word16 ByteString) -> Map EntrySelector (Map Word16 ()) -> Map EntrySelector Word32 -> EditingActions
[eaCompression] :: EditingActions -> Map EntrySelector CompressionMethod
[eaEntryComment] :: EditingActions -> Map EntrySelector Text
[eaDeleteComment] :: EditingActions -> Map EntrySelector ()
[eaModTime] :: EditingActions -> Map EntrySelector UTCTime
[eaExtraField] :: EditingActions -> Map EntrySelector (Map Word16 ByteString)
[eaDeleteField] :: EditingActions -> Map EntrySelector (Map Word16 ())
[eaExtFileAttr] :: EditingActions -> Map EntrySelector Word32

-- | The origin of entries that can be streamed into archive.
data EntryOrigin
GenericOrigin :: EntryOrigin
StrictOrigin :: Natural -> EntryOrigin
Borrowed :: EntryDescription -> EntryOrigin

-- | The type of the file header: local or central directory.
data HeaderType
LocalHeader :: EntryOrigin -> HeaderType
CentralDirHeader :: HeaderType

-- | The data descriptor representation.
data DataDescriptor
DataDescriptor :: Word32 -> Natural -> Natural -> DataDescriptor
[ddCRC32] :: DataDescriptor -> Word32
[ddCompressedSize] :: DataDescriptor -> Natural
[ddUncompressedSize] :: DataDescriptor -> Natural

-- | A temporary data structure to hold Zip64 extra data field information.
data Zip64ExtraField
Zip64ExtraField :: Natural -> Natural -> Natural -> Zip64ExtraField
[z64efUncompressedSize] :: Zip64ExtraField -> Natural
[z64efCompressedSize] :: Zip64ExtraField -> Natural
[z64efOffset] :: Zip64ExtraField -> Natural

-- | MS-DOS date-time: a pair of Word16 (date, time) with the
--   following structure:
--   
--   
--   DATE bit     0 - 4           5 - 8           9 - 15
--        value   day (1 - 31)    month (1 - 12)  years from 1980
--   TIME bit     0 - 4           5 - 10          11 - 15
--        value   seconds*        minute          hour
--                *stored in two-second increments
--   
data MsDosTime
MsDosTime :: Word16 -> Word16 -> MsDosTime
[msDosDate] :: MsDosTime -> Word16
[msDosTime] :: MsDosTime -> Word16

-- | “Version created by” to specify when writing archive data.
zipVersion :: Version

-- | Scan the central directory of an archive and return its description
--   ArchiveDescription as well as a collection of its entries.
--   
--   This operation may fail with:
--   
--   
--   
- isAlreadyInUseError if the file is already open and
--   cannot be reopened;
--   
- isDoesNotExistError if the file does not exist;
--   
- isPermissionError if the user does not have permission to
--   open the file;
--   
- ParsingFailed when specified archive is something this
--   library cannot parse (this includes multi-disk archives, for
--   example).
--   
--   
--   Please note that entries with invalid (non-portable) file names may be
--   missing in the list of entries. Files that are compressed with
--   unsupported compression methods are skipped as well. Also, if several
--   entries would collide on some operating systems (such as Windows,
--   because of its case-insensitivity), only one of them will be
--   available, because EntrySelector is case-insensitive. These are
--   the consequences of the design decision to make it impossible to
--   create non-portable archives with this library.
scanArchive :: FilePath -> IO (ArchiveDescription, Map EntrySelector EntryDescription)

-- | Given location of the archive and information about a specific archive
--   entry EntryDescription, return Source of its data. The
--   actual data can be compressed or uncompressed depending on the third
--   argument.
sourceEntry :: forall (m :: Type -> Type). (PrimMonad m, MonadThrow m, MonadResource m) => FilePath -> EntryDescription -> Bool -> ConduitT () ByteString m ()

-- | Undertake all actions specified as the fourth argument of the
--   function. This transforms the given pending actions so they can be
--   performed in one pass, and then they are applied in the most efficient
--   way.
commit :: FilePath -> ArchiveDescription -> Map EntrySelector EntryDescription -> Seq PendingAction -> IO ()

-- | Create a new file with the guarantee that in the case of an exception
--   the old file will be intact. The file is only updated/replaced if the
--   second argument finishes without exceptions.
withNewFile :: FilePath -> (Handle -> IO ()) -> IO ()

-- | Determine what comment in new archive will look like given its
--   original value and a collection of pending actions.
predictComment :: Maybe Text -> Seq PendingAction -> Maybe Text

-- | Transform a map representing existing entries into a collection of
--   actions that re-create those entires.
toRecreatingActions :: FilePath -> Map EntrySelector EntryDescription -> Seq PendingAction

-- | Transform a collection of PendingActions into
--   ProducingActions and EditingActions—data that describes
--   how to create resulting archive.
optimize :: Seq PendingAction -> (ProducingActions, EditingActions)

-- | Copy entries from another archive and write them into the file
--   associated with the given handle. This can throw
--   EntryDoesNotExist if there is no such entry in that archive.
copyEntries :: Handle -> FilePath -> Map EntrySelector EntrySelector -> EditingActions -> IO (Map EntrySelector EntryDescription)

-- | Sink an entry from the given stream into the file associated with the
--   given Handle.
sinkEntry :: Handle -> EntrySelector -> EntryOrigin -> ConduitT () ByteString (ResourceT IO) () -> EditingActions -> IO EntryDescription

-- | Create a Sink to stream data there. Once streaming is
--   finished, return DataDescriptor for the streamed data. The
--   action does not close the given Handle.
sinkData :: Handle -> CompressionMethod -> ConduitT ByteString Void (ResourceT IO) DataDescriptor

-- | Append central directory entries and the end of central directory
--   record to the file that given Handle is associated with. Note
--   that this automatically writes Zip64 end of central directory record
--   and Zip64 end of central directory locator when necessary.
writeCD :: Handle -> Maybe Text -> Map EntrySelector EntryDescription -> IO ()

-- | Extract the number of bytes between the start of file name in local
--   header and the start of actual data.
getLocalHeaderGap :: Get Integer

-- | Parse central directory file headers and put them into a Map.
getCD :: Get (Map EntrySelector EntryDescription)

-- | Parse a single central directory file header. If it's a directory or
--   file compressed with unsupported compression method, Nothing is
--   returned.
getCDHeader :: Get (Maybe (EntrySelector, EntryDescription))

-- | Parse an extra-field.
getExtraField :: Get (Word16, ByteString)

-- | Get signature. If the extracted data is not equal to the provided
--   signature, fail.
getSignature :: Word32 -> Get ()

-- | Parse Zip64ExtraField from its binary representation.
parseZip64ExtraField :: Zip64ExtraField -> ByteString -> Zip64ExtraField

-- | Produce binary representation of Zip64ExtraField.
makeZip64ExtraField :: HeaderType -> Zip64ExtraField -> ByteString

-- | Create ByteString representing an extra field.
putExtraField :: Map Word16 ByteString -> Put

-- | Create ByteString representing the entire central directory.
putCD :: Map EntrySelector EntryDescription -> Put

-- | Create ByteString representing either a local file header or a
--   central directory file header.
putHeader :: HeaderType -> EntrySelector -> EntryDescription -> Put

-- | Create ByteString representing Zip64 end of central directory
--   record.
putZip64ECD :: Natural -> Natural -> Natural -> Put

-- | Create ByteString representing Zip64 end of the central
--   directory locator.
putZip64ECDLocator :: Natural -> Put

-- | Parse end of the central directory record or Zip64 end of the central
--   directory record depending on signature binary data begins with.
getECD :: Get ArchiveDescription

-- | Create a ByteString representing the end of central directory
--   record.
putECD :: Natural -> Natural -> Natural -> Maybe Text -> Put

-- | Find the absolute offset of the end of central directory record or, if
--   present, Zip64 end of central directory record.
locateECD :: FilePath -> Handle -> IO (Maybe Integer)

-- | Rename an entry (key) in a Map.
renameKey :: Ord k => k -> k -> Map k a -> Map k a

-- | Like fromIntegral, but with saturation when converting to
--   bounded types.
withSaturation :: (Integral a, Integral b, Bounded b) => a -> b

-- | Determine the target entry of an action.
targetEntry :: PendingAction -> Maybe EntrySelector

-- | Decode a ByteString. The first argument indicates whether we
--   should treat it as UTF-8 (in case bit 11 of general-purpose bit flag
--   is set), otherwise the function assumes CP437. Note that since not
--   every stream of bytes constitutes valid UTF-8 text, this function can
--   fail. In that case Nothing is returned.
decodeText :: Bool -> ByteString -> Maybe Text

-- | Detect if the given text needs newer Unicode-aware features to be
--   properly encoded in the archive.
needsUnicode :: Text -> Bool

-- | Convert numeric representation (as per the .ZIP specification) of
--   version into Version.
toVersion :: Word16 -> Version

-- | Covert Version to its numeric representation as per the .ZIP
--   specification.
fromVersion :: Version -> Word16

-- | Get the compression method form its numeric representation.
toCompressionMethod :: Word16 -> Maybe CompressionMethod

-- | Convert CompressionMethod to its numeric representation as per
--   the .ZIP specification.
fromCompressionMethod :: CompressionMethod -> Word16

-- | Check if an entry with these parameters needs the Zip64 extension.
needsZip64 :: EntryDescription -> Bool

-- | Check if an entry has Zip64 extra fields.
entryUsesZip64 :: EntryDescription -> Bool

-- | Determine “version needed to extract” that should be written to the
--   headers given the need of the Zip64 feature and the compression
--   method.
getZipVersion :: Bool -> Maybe CompressionMethod -> Version

-- | Return a decompressing Conduit corresponding to the given
--   compression method.
decompressingPipe :: forall (m :: Type -> Type). (PrimMonad m, MonadThrow m, MonadResource m) => CompressionMethod -> ConduitT ByteString ByteString m ()

-- | A sink that calculates the CRC32 check sum for an incoming stream.
crc32Sink :: ConduitT ByteString Void (ResourceT IO) Word32

-- | Convert UTCTime to the MS-DOS time format.
toMsDosTime :: UTCTime -> MsDosTime

-- | Convert MS-DOS date-time to UTCTime.
fromMsDosTime :: MsDosTime -> UTCTime
ffff :: Natural
ffffffff :: Natural

-- | The default permissions for the files, permissions not set on Windows,
--   and are set to rw on Unix. This mimics the behavior of the zip
--   utility.
defaultFileMode :: Word32
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.EntryOrigin
instance GHC.Classes.Eq Codec.Archive.Zip.Internal.HeaderType

-- | The module provides everything you may need to manipulate Zip
--   archives. There are three things that should be clarified right away,
--   to avoid confusion.
--   
--   First, we use the EntrySelector type that can be obtained from
--   relative FilePaths (paths to directories are not allowed). This
--   method may seem awkward at first, but it will protect you from the
--   problems with portability when your archive is unpacked on a different
--   platform.
--   
--   Second, there is no way to add directories, or to be precise, /empty
--   directories/ to your archive. This approach is used in Git, and I find
--   it sane.
--   
--   Finally, the third feature of the library is that it does not modify
--   archive instantly, because doing so on every manipulation would often
--   be inefficient. Instead, we maintain a collection of pending actions
--   that can be turned into an optimized procedure that efficiently
--   modifies the archive in one pass. Normally, this should be of no
--   concern to you, because all actions are performed automatically when
--   you leave the ZipArchive monad. If, however, you ever need to
--   force an update, the commit function is your friend.
--   
--   
Examples
--   
--   An example of a program that prints a list of archive entries:
--   
--   
--   import Codec.Archive.Zip
--   import System.Environment (getArgs)
--   import qualified Data.Map as M
--   
--   main :: IO ()
--   main = do
--     [path]  <- getArgs
--     entries <- withArchive path (M.keys <$> getEntries)
--     mapM_ print entries
--   
--   
--   Create a Zip archive with a “Hello World” file:
--   
--   
--   import Codec.Archive.Zip
--   import System.Environment (getArgs)
--   
--   main :: IO ()
--   main = do
--     [path] <- getArgs
--     s      <- mkEntrySelector "hello-world.txt"
--     createArchive path (addEntry Store "Hello, World!" s)
--   
--   
--   Extract contents of a file and print them:
--   
--   
--   import Codec.Archive.Zip
--   import System.Environment (getArgs)
--   import qualified Data.ByteString.Char8 as B
--   
--   main :: IO ()
--   main = do
--     [path,f] <- getArgs
--     s        <- mkEntrySelector f
--     bs       <- withArchive path (getEntry s)
--     B.putStrLn bs
--   
module Codec.Archive.Zip

-- | This data type serves for naming and selection of archive entries. It
--   can be created only with the help of the smart constructor
--   mkEntrySelector, and it's the only “key” that can be used to
--   refer to files in the archive or to name new archive entries.
--   
--   The abstraction is crucial for ensuring that created archives are
--   portable across operating systems, file systems, and 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 the archive for compatibility with
--   Unix-like operating systems (as recommended in the specification). On
--   the other hand, in can be rendered as an ordinary relative file path
--   in OS-specific format when needed.
data EntrySelector

-- | Create an EntrySelector from a FilePath. To avoid
--   problems with distribution of the archive, characters that some
--   operating systems do not expect in paths are not allowed.
--   
--   Argument to mkEntrySelector should pass these checks:
--   
--   
--   
- isValid
--   
- isValid
--   
- it is a relative path without slash at the end
--   
- binary representations of normalized path should be not longer
--   than 65535 bytes
--   
--   
--   This function can throw an EntrySelectorException.
mkEntrySelector :: MonadThrow m => FilePath -> m EntrySelector

-- | Restore a relative path from EntrySelector. Every
--   EntrySelector corresponds to a FilePath.
unEntrySelector :: EntrySelector -> FilePath

-- | Get an entry name in the from that is suitable for writing to file
--   header, given an EntrySelector.
getEntryName :: EntrySelector -> Text

-- | The problems you can have with an EntrySelector.
newtype EntrySelectorException

-- | EntrySelector cannot be created from this path
InvalidEntrySelector :: FilePath -> EntrySelectorException

-- | The 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 representations can be built given this
--   data structure and the archive contents.
data EntryDescription
EntryDescription :: Version -> Version -> CompressionMethod -> UTCTime -> Word32 -> Natural -> Natural -> Natural -> Maybe Text -> Map Word16 ByteString -> Word32 -> EntryDescription

-- | Version made by
[edVersionMadeBy] :: EntryDescription -> Version

-- | Version needed to extract
[edVersionNeeded] :: EntryDescription -> Version

-- | Compression method
[edCompression] :: EntryDescription -> CompressionMethod

-- | Last modification date and time
[edModTime] :: EntryDescription -> UTCTime

-- | CRC32 check sum
[edCRC32] :: EntryDescription -> Word32

-- | Size of compressed entry
[edCompressedSize] :: EntryDescription -> Natural

-- | Size of uncompressed entry
[edUncompressedSize] :: EntryDescription -> Natural

-- | Absolute offset of local file header
[edOffset] :: EntryDescription -> Natural

-- | Entry comment
[edComment] :: EntryDescription -> Maybe Text

-- | All extra fields found
[edExtraField] :: EntryDescription -> Map Word16 ByteString

-- | External file attributes
[edExternalFileAttrs] :: EntryDescription -> Word32

-- | The supported compression methods.
data CompressionMethod

-- | Store file uncompressed
Store :: CompressionMethod

-- | Deflate
Deflate :: CompressionMethod

-- | Compressed using BZip2 algorithm
BZip2 :: CompressionMethod

-- | Compressed using Zstandard algorithm
Zstd :: CompressionMethod

-- | The information about the archive as a whole.
data ArchiveDescription
ArchiveDescription :: Maybe Text -> Natural -> Natural -> ArchiveDescription

-- | The comment of the entire archive
[adComment] :: ArchiveDescription -> Maybe Text

-- | Absolute offset of the start of central directory
[adCDOffset] :: ArchiveDescription -> Natural

-- | The size of central directory record
[adCDSize] :: ArchiveDescription -> Natural

-- | The bad things that can happen when you use the library.
data ZipException

-- | Thrown when you try to get contents of non-existing entry
EntryDoesNotExist :: FilePath -> EntrySelector -> ZipException

-- | Thrown when attempting to decompress an entry compressed with an
--   unsupported compression method or the library is compiled without
--   support for it.
UnsupportedCompressionMethod :: CompressionMethod -> ZipException

-- | Thrown when archive structure cannot be parsed.
ParsingFailed :: FilePath -> String -> ZipException

-- | Monad that provides context necessary for performing operations on zip
--   archives. It's intentionally opaque and not a monad transformer to
--   limit the actions that can be performed in it to those provided by
--   this module and their combinations.
data ZipArchive a

-- | The internal state record used by the ZipArchive monad. This is
--   only exported for use with MonadBaseControl methods, you can't
--   look inside.
data ZipState

-- | Create a new archive given its location and an action that describes
--   how to create contents of the archive. This will silently overwrite
--   the specified file if it already exists. See withArchive if you
--   want to work with an existing archive.
createArchive :: MonadIO m => FilePath -> ZipArchive a -> m a

-- | Work with an existing archive. See createArchive if you want to
--   create a new archive instead.
--   
--   This operation may fail with:
--   
--   
--   
- isAlreadyInUseError if the file is already open and
--   cannot be reopened;
--   
- isDoesNotExistError if the file does not exist;
--   
- isPermissionError if the user does not have permission to
--   open the file;
--   
- ParsingFailed when specified archive is something this
--   library cannot parse (this includes multi-disk archives, for
--   example).
--   
--   
--   Please note that entries with invalid (non-portable) file names may be
--   missing in the list of entries. Files that are compressed with
--   unsupported compression methods are skipped as well. Also, if several
--   entries would collide on some operating systems (such as Windows,
--   because of its case-insensitivity), only one of them will be
--   available, because EntrySelector is case-insensitive. These are
--   the consequences of the design decision to make it impossible to
--   create non-portable archives with this library.
withArchive :: MonadIO m => FilePath -> ZipArchive a -> m a

-- | Retrieve a description of all archive entries. This is an efficient
--   operation that can be used for example to list all entries in the
--   archive. Do not hesitate to use the function frequently: scanning of
--   the archive happens only once.
--   
--   Please note that the returned value only reflects the current contents
--   of the archive in file system, non-committed actions are not
--   reflected, see commit for more information.
getEntries :: ZipArchive (Map EntrySelector EntryDescription)

-- | Check whether the specified entry exists in the archive. This is a
--   simple shortcut defined as:
--   
--   
--   doesEntryExist s = M.member s <$> getEntries
--   
doesEntryExist :: EntrySelector -> ZipArchive Bool

-- | Get EntryDescription for a specified entry. This is a simple
--   shortcut defined as:
--   
--   
--   getEntryDesc s = M.lookup s <$> getEntries
--   
getEntryDesc :: EntrySelector -> ZipArchive (Maybe EntryDescription)

-- | Get contents of a specific archive entry as a strict
--   ByteString. It's not recommended to use this on big entries,
--   because it will suck out a lot of memory. For big entries, use
--   conduits: sourceEntry.
--   
--   Throws: EntryDoesNotExist.
getEntry :: EntrySelector -> ZipArchive ByteString

-- | Get an entry source.
--   
--   Throws: EntryDoesNotExist.
getEntrySource :: forall (m :: Type -> Type). (PrimMonad m, MonadThrow m, MonadResource m) => EntrySelector -> ZipArchive (ConduitT () ByteString m ())

-- | Stream contents of an archive entry to the given Sink.
--   
--   Throws: EntryDoesNotExist.
sourceEntry :: EntrySelector -> ConduitT ByteString Void (ResourceT IO) a -> ZipArchive a

-- | Save a specific archive entry as a file in the file system.
--   
--   Throws: EntryDoesNotExist.
saveEntry :: EntrySelector -> FilePath -> ZipArchive ()

-- | Calculate CRC32 check sum and compare it with the value read from the
--   archive. The function returns True when the check sums are the
--   same—that is, the data is not corrupted.
--   
--   Throws: EntryDoesNotExist.
checkEntry :: EntrySelector -> ZipArchive Bool

-- | Unpack the archive into the specified directory. The directory will be
--   created if it does not exist.
unpackInto :: FilePath -> ZipArchive ()

-- | Get the archive comment.
getArchiveComment :: ZipArchive (Maybe Text)

-- | Get the archive description record.
getArchiveDescription :: ZipArchive ArchiveDescription

-- | Add a new entry to the archive given its contents in binary form.
addEntry :: CompressionMethod -> ByteString -> EntrySelector -> ZipArchive ()

-- | Stream data from the specified source to an archive entry.
sinkEntry :: CompressionMethod -> ConduitT () ByteString (ResourceT IO) () -> EntrySelector -> ZipArchive ()

-- | Load an entry from a given file.
loadEntry :: CompressionMethod -> EntrySelector -> FilePath -> ZipArchive ()

-- | Copy an entry “as is” from another zip archive. If the entry does not
--   exist in that archive, EntryDoesNotExist will be thrown.
copyEntry :: FilePath -> EntrySelector -> EntrySelector -> ZipArchive ()

-- | Add an directory to the archive. Please note that due to the design of
--   the library, empty sub-directories will not be added.
--   
--   The action can throw InvalidEntrySelector.
packDirRecur :: CompressionMethod -> (FilePath -> ZipArchive EntrySelector) -> FilePath -> ZipArchive ()

-- | The same as packDirRecur but allows us to perform modifying
--   actions on the created entities as we go.
packDirRecur' :: CompressionMethod -> (FilePath -> ZipArchive EntrySelector) -> (EntrySelector -> ZipArchive ()) -> FilePath -> ZipArchive ()

-- | Rename an entry in the archive. If the entry does not exist, nothing
--   will happen.
renameEntry :: EntrySelector -> EntrySelector -> ZipArchive ()

-- | Delete an entry from the archive, if it does not exist, nothing will
--   happen.
deleteEntry :: EntrySelector -> ZipArchive ()

-- | Change compression method of an entry, if it does not exist, nothing
--   will happen.
recompress :: CompressionMethod -> EntrySelector -> ZipArchive ()

-- | Set an entry comment, if that entry does not exist, nothing will
--   happen. Note that if binary representation of the comment is longer
--   than 65535 bytes, it will be truncated on writing.
setEntryComment :: Text -> EntrySelector -> ZipArchive ()

-- | Delete an entry's comment, if that entry does not exist, nothing will
--   happen.
deleteEntryComment :: EntrySelector -> ZipArchive ()

-- | Set the last modification date/time. The specified entry may be
--   missing, in that case the action has no effect.
setModTime :: UTCTime -> EntrySelector -> ZipArchive ()

-- | Add an extra field. The specified entry may be missing, in that case
--   this action has no effect.
addExtraField :: Word16 -> ByteString -> EntrySelector -> ZipArchive ()

-- | Delete an extra field by its type (tag). The specified entry may be
--   missing, in that case this action has no effect.
deleteExtraField :: Word16 -> EntrySelector -> ZipArchive ()

-- | Set external file attributes. This function can be used to set file
--   permissions.
--   
--   See also: Codec.Archive.Zip.Unix.
setExternalFileAttrs :: Word32 -> EntrySelector -> ZipArchive ()

-- | Perform an action on every entry in the archive.
forEntries :: (EntrySelector -> ZipArchive ()) -> ZipArchive ()

-- | Set the comment of the entire archive.
setArchiveComment :: Text -> ZipArchive ()

-- | Delete the archive's comment if it's present.
deleteArchiveComment :: ZipArchive ()

-- | Undo the changes to a specific archive entry.
undoEntryChanges :: EntrySelector -> ZipArchive ()

-- | Undo the changes to the archive as a whole (archive's comment).
undoArchiveChanges :: ZipArchive ()

-- | Undo all changes made in this editing session.
undoAll :: ZipArchive ()

-- | Archive contents are not modified instantly, but instead changes are
--   collected as “pending actions” that should be committed, in order to
--   efficiently modify the archive in one pass. The actions are committed
--   automatically when the program leaves the ZipArchive monad
--   (i.e. as part of createArchive or withArchive), or can
--   be forced explicitly with the help of this function. Once committed,
--   changes take place in the file system and cannot be undone.
commit :: ZipArchive ()
instance GHC.Internal.Base.Applicative Codec.Archive.Zip.ZipArchive
instance GHC.Internal.Base.Functor Codec.Archive.Zip.ZipArchive
instance Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO Codec.Archive.Zip.ZipArchive
instance Control.Monad.Base.MonadBase GHC.Types.IO Codec.Archive.Zip.ZipArchive
instance Control.Monad.Catch.MonadCatch Codec.Archive.Zip.ZipArchive
instance Control.Monad.IO.Class.MonadIO Codec.Archive.Zip.ZipArchive
instance Control.Monad.Catch.MonadMask Codec.Archive.Zip.ZipArchive
instance Control.Monad.Catch.MonadThrow Codec.Archive.Zip.ZipArchive
instance GHC.Internal.Base.Monad Codec.Archive.Zip.ZipArchive
