module Codec.Archive.Zip.Conduit.Types where
import Control.Exception (Exception(..))
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as BSL
import qualified Data.Conduit as C
import Data.Conduit.Binary (sourceLbs)
import Data.Semigroup (Semigroup(..))
import Data.String (IsString(..))
import qualified Data.Text as T
import Data.Time.LocalTime (LocalTime)
import Data.Typeable (Typeable)
import Data.Word (Word32, Word64)
newtype ZipError = ZipError String
deriving (Int -> ZipError -> ShowS
[ZipError] -> ShowS
ZipError -> String
(Int -> ZipError -> ShowS)
-> (ZipError -> String) -> ([ZipError] -> ShowS) -> Show ZipError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZipError] -> ShowS
$cshowList :: [ZipError] -> ShowS
show :: ZipError -> String
$cshow :: ZipError -> String
showsPrec :: Int -> ZipError -> ShowS
$cshowsPrec :: Int -> ZipError -> ShowS
Show, Typeable)
instance IsString ZipError where
fromString :: String -> ZipError
fromString = String -> ZipError
ZipError
instance Exception ZipError where
displayException :: ZipError -> String
displayException (ZipError String
e) = String
"ZipError: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
e
data ZipInfo = ZipInfo
{ :: ByteString
} deriving (ZipInfo -> ZipInfo -> Bool
(ZipInfo -> ZipInfo -> Bool)
-> (ZipInfo -> ZipInfo -> Bool) -> Eq ZipInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ZipInfo -> ZipInfo -> Bool
$c/= :: ZipInfo -> ZipInfo -> Bool
== :: ZipInfo -> ZipInfo -> Bool
$c== :: ZipInfo -> ZipInfo -> Bool
Eq, Int -> ZipInfo -> ShowS
[ZipInfo] -> ShowS
ZipInfo -> String
(Int -> ZipInfo -> ShowS)
-> (ZipInfo -> String) -> ([ZipInfo] -> ShowS) -> Show ZipInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZipInfo] -> ShowS
$cshowList :: [ZipInfo] -> ShowS
show :: ZipInfo -> String
$cshow :: ZipInfo -> String
showsPrec :: Int -> ZipInfo -> ShowS
$cshowsPrec :: Int -> ZipInfo -> ShowS
Show)
data ZipEntry = ZipEntry
{ ZipEntry -> Either Text ByteString
zipEntryName :: Either T.Text ByteString
, ZipEntry -> LocalTime
zipEntryTime :: LocalTime
, ZipEntry -> Maybe Word64
zipEntrySize :: Maybe Word64
, ZipEntry -> Maybe Word32
zipEntryExternalAttributes :: Maybe Word32
} deriving (ZipEntry -> ZipEntry -> Bool
(ZipEntry -> ZipEntry -> Bool)
-> (ZipEntry -> ZipEntry -> Bool) -> Eq ZipEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ZipEntry -> ZipEntry -> Bool
$c/= :: ZipEntry -> ZipEntry -> Bool
== :: ZipEntry -> ZipEntry -> Bool
$c== :: ZipEntry -> ZipEntry -> Bool
Eq, Int -> ZipEntry -> ShowS
[ZipEntry] -> ShowS
ZipEntry -> String
(Int -> ZipEntry -> ShowS)
-> (ZipEntry -> String) -> ([ZipEntry] -> ShowS) -> Show ZipEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZipEntry] -> ShowS
$cshowList :: [ZipEntry] -> ShowS
show :: ZipEntry -> String
$cshow :: ZipEntry -> String
showsPrec :: Int -> ZipEntry -> ShowS
$cshowsPrec :: Int -> ZipEntry -> ShowS
Show)
data ZipData m
= ZipDataByteString BSL.ByteString
| ZipDataSource (C.ConduitM () ByteString m ())
instance Monad m => Semigroup (ZipData m) where
ZipDataByteString ByteString
a <> :: ZipData m -> ZipData m -> ZipData m
<> ZipDataByteString ByteString
b = ByteString -> ZipData m
forall (m :: * -> *). ByteString -> ZipData m
ZipDataByteString (ByteString -> ZipData m) -> ByteString -> ZipData m
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString -> ByteString
forall a. Monoid a => a -> a -> a
mappend ByteString
a ByteString
b
ZipData m
a <> ZipData m
b = ConduitM () ByteString m () -> ZipData m
forall (m :: * -> *). ConduitM () ByteString m () -> ZipData m
ZipDataSource (ConduitM () ByteString m () -> ZipData m)
-> ConduitM () ByteString m () -> ZipData m
forall a b. (a -> b) -> a -> b
$ ConduitM () ByteString m ()
-> ConduitM () ByteString m () -> ConduitM () ByteString m ()
forall a. Monoid a => a -> a -> a
mappend (ZipData m -> ConduitM () ByteString m ()
forall (m :: * -> *).
Monad m =>
ZipData m -> ConduitM () ByteString m ()
sourceZipData ZipData m
a) (ZipData m -> ConduitM () ByteString m ()
forall (m :: * -> *).
Monad m =>
ZipData m -> ConduitM () ByteString m ()
sourceZipData ZipData m
b)
instance Monad m => Monoid (ZipData m) where
mempty :: ZipData m
mempty = ByteString -> ZipData m
forall (m :: * -> *). ByteString -> ZipData m
ZipDataByteString ByteString
BSL.empty
mappend :: ZipData m -> ZipData m -> ZipData m
mappend = ZipData m -> ZipData m -> ZipData m
forall a. Semigroup a => a -> a -> a
(<>)
sourceZipData :: Monad m => ZipData m -> C.ConduitM () ByteString m ()
sourceZipData :: ZipData m -> ConduitM () ByteString m ()
sourceZipData (ZipDataByteString ByteString
b) = ByteString -> ConduitM () ByteString m ()
forall (m :: * -> *) i.
Monad m =>
ByteString -> ConduitT i ByteString m ()
sourceLbs ByteString
b
sourceZipData (ZipDataSource ConduitM () ByteString m ()
s) = ConduitM () ByteString m ()
s