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


-- | Parse tar files using conduit for streaming
--   
--   Please see README.md
@package tar-conduit
@version 0.1.1


-- | This module is about stream-processing tar archives. It is currently
--   not very well tested. See the documentation of <a>withEntries</a> for
--   an usage sample.
module Data.Conduit.Tar
untar :: Monad m => ConduitM ByteString TarChunk m ()

-- | Process a single tar entry. See <a>withEntries</a> for more details.
withEntry :: MonadThrow m => (Header -> ConduitM ByteString o m r) -> ConduitM TarChunk o m r

-- | This function handles each entry of the tar archive according to the
--   behaviour of the function passed as first argument.
--   
--   Here is a full example function, that reads a compressed tar archive
--   and for each entry that is a simple file, it prints its file path and
--   SHA256 digest. Note that this function can throw exceptions!
--   
--   <pre>
--   import qualified Crypto.Hash.Conduit as CH
--   import qualified Data.Conduit.Tar    as CT
--   
--   import Conduit
--   import Crypto.Hash (Digest, SHA256)
--   import Control.Monad (when)
--   import Data.Conduit.Zlib (ungzip)
--   import Data.ByteString (ByteString)
--   
--   filedigests :: FilePath -&gt; IO ()
--   filedigests fp = runConduitRes (  sourceFileBS fp          -- read the raw file
--                                  .| ungzip                   -- gunzip
--                                  .| CT.untar                 -- decode the tar archive
--                                  .| CT.withEntries hashentry -- process each file
--                                  .| printC                   -- print the results
--                                  )
--       where
--           hashentry :: Monad m =&gt; CT.Header -&gt; Conduit ByteString m (FilePath, Digest SHA256)
--           hashentry hdr = when (CT.headerFileType hdr == CT.FTNormal) $ do
--               hash &lt;- CH.sinkHash
--               yield (CT.headerFilePath hdr, hash)
--   </pre>
--   
--   The <tt>hashentry</tt> function handles a single entry, based on its
--   first <a>Header</a> argument. In this example, a <a>Consumer</a> is
--   used to process the whole entry.
--   
--   Note that the benefits of stream processing are easily lost when
--   working with a <a>Consumer</a>. For example, the following
--   implementation would have used an unbounded amount of memory:
--   
--   <pre>
--   hashentry hdr = when (CT.headerFileType hdr == CT.FTNormal) $ do
--       content &lt;- mconcat &lt;$&gt; sinkList
--       yield (CT.headerFilePath hdr, hash content)
--   </pre>
withEntries :: MonadThrow m => (Header -> ConduitM ByteString o m ()) -> ConduitM TarChunk o m ()
headerFileType :: Header -> FileType
headerFilePath :: Header -> FilePath
data Header
Header :: !Offset -> !Offset -> !ShortByteString -> !CMode -> !Int -> !Int -> !Size -> !Int64 -> !Word8 -> !ShortByteString -> !ShortByteString -> !Int -> !Int -> !ShortByteString -> Header
[headerOffset] :: Header -> !Offset
[headerPayloadOffset] :: Header -> !Offset
[headerFileNameSuffix] :: Header -> !ShortByteString
[headerFileMode] :: Header -> !CMode
[headerOwnerId] :: Header -> !Int
[headerGroupId] :: Header -> !Int
[headerPayloadSize] :: Header -> !Size
[headerTime] :: Header -> !Int64
[headerLinkIndicator] :: Header -> !Word8
[headerOwnerName] :: Header -> !ShortByteString
[headerGroupName] :: Header -> !ShortByteString
[headerDeviceMajor] :: Header -> !Int
[headerDeviceMinor] :: Header -> !Int
[headerFileNamePrefix] :: Header -> !ShortByteString
data TarChunk
ChunkHeader :: Header -> TarChunk
ChunkPayload :: !Offset -> !ByteString -> TarChunk
ChunkException :: TarException -> TarChunk

-- | This the the exception type that is used in this module.
--   
--   More constructors are susceptible to be added without bumping the
--   major version of this module.
data TarException
NoMoreHeaders :: TarException
UnexpectedPayload :: !Offset -> TarException
IncompleteHeader :: !Offset -> TarException
IncompletePayload :: !Offset -> !Size -> TarException
ShortTrailer :: !Offset -> TarException
BadTrailer :: !Offset -> TarException
InvalidHeader :: !Offset -> TarException
BadChecksum :: !Offset -> TarException
type Offset = Int
type Size = Int
data FileType
FTNormal :: FileType
FTHardLink :: FileType
FTSymbolicLink :: FileType
FTCharacterSpecial :: FileType
FTBlockSpecial :: FileType
FTDirectory :: FileType
FTFifo :: FileType
FTOther :: !Word8 -> FileType
instance GHC.Show.Show Data.Conduit.Tar.TarChunk
instance GHC.Show.Show Data.Conduit.Tar.TarException
instance GHC.Show.Show Data.Conduit.Tar.Header
instance GHC.Classes.Eq Data.Conduit.Tar.FileType
instance GHC.Show.Show Data.Conduit.Tar.FileType
instance GHC.Exception.Exception Data.Conduit.Tar.TarException
