lzma-conduit 0.1.2 → 0.1.2.1
raw patch · 2 files changed
+35/−15 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- lzma-conduit.cabal +2/−2
- src/Data/Conduit/Lzma.hs +33/−13
lzma-conduit.cabal view
@@ -1,5 +1,5 @@ name: lzma-conduit-version: 0.1.2+version: 0.1.2.1 synopsis: Conduit interface for lzma/xz compression. description: High level bindings to xz-utils.@@ -10,7 +10,7 @@ maintainer: Nathan Howell <nhowell@alphaheavy.com> homepage: http://github.com/alphaHeavy/lzma-conduit bug-reports: http://github.com/alphaHeavy/lzma-conduit/issues-category: Codec, Compression, Enumerator+category: Codec, Compression, Conduit build-type: Simple cabal-version: >= 1.10
src/Data/Conduit/Lzma.hs view
@@ -16,7 +16,9 @@ import Bindings.Lzma -prettyRet :: C'lzma_ret -> String+prettyRet+ :: C'lzma_ret+ -> String prettyRet r | r == c'LZMA_OK = "Operation completed successfully" | r == c'LZMA_STREAM_END = "End of stream was reached"@@ -32,10 +34,15 @@ | r == c'LZMA_PROG_ERROR = "Programming error" | otherwise = "Unknown LZMA error: "++show r -bufferSize :: Num a => a+bufferSize+ :: Num a => a bufferSize = 4096 -memset :: forall a . Storable a => Ptr a -> Word8 -> IO ()+memset+ :: forall a . Storable a+ => Ptr a+ -> Word8+ -> IO () memset ptr val = forM_ [0..sizeOf (undefined :: a) - 1] $ \ i -> pokeByteOff ptr i val@@ -60,11 +67,19 @@ then return streamPtr else fail $ name ++ " failed: " ++ prettyRet ret -easyEncoder :: Maybe Int -> Ptr C'lzma_stream -> IO C'lzma_ret-easyEncoder level ptr = c'lzma_easy_encoder ptr (maybe c'LZMA_PRESET_DEFAULT fromIntegral level) c'LZMA_CHECK_CRC64+easyEncoder+ :: Maybe Int+ -> Ptr C'lzma_stream+ -> IO C'lzma_ret+easyEncoder level ptr =+ c'lzma_easy_encoder ptr (maybe c'LZMA_PRESET_DEFAULT fromIntegral level) c'LZMA_CHECK_CRC64 -autoDecoder :: Maybe Word64 -> Ptr C'lzma_stream -> IO C'lzma_ret-autoDecoder memlimit ptr = c'lzma_auto_decoder ptr (maybe maxBound fromIntegral memlimit) 0+autoDecoder+ :: Maybe Word64+ -> Ptr C'lzma_stream+ -> IO C'lzma_ret+autoDecoder memlimit ptr =+ c'lzma_auto_decoder ptr (maybe maxBound fromIntegral memlimit) 0 -- | Decompress a 'ByteString' from a lzma or xz container stream. decompress@@ -94,7 +109,8 @@ :: ResourceIO m => Ptr C'lzma_stream -> Conduit ByteString m ByteString-lzmaConduit = liftM2 Conduit lzmaPush lzmaClose+lzmaConduit =+ liftM2 Conduit lzmaPush lzmaClose lzmaPush :: ResourceIO m@@ -103,10 +119,10 @@ -> ResourceT m (ConduitResult ByteString m ByteString) lzmaPush streamPtr xs = do chunks <- liftIO $ codeEnum streamPtr xs- return $ Producing (lzmaConduit streamPtr) chunks+ return $! Producing (lzmaConduit streamPtr) chunks lzmaClose- :: Control.Monad.IO.Class.MonadIO m+ :: MonadIO m => Ptr C'lzma_stream -> m [ByteString] lzmaClose streamPtr = liftIO $@@ -151,7 +167,8 @@ then return [x] else do -- run lzma_code forward just far enough to read all the input buffer- xs <- unsafeInterleaveIO $ buildChunks streamPtr action status+ -- xs <- unsafeInterleaveIO $ buildChunks streamPtr action status+ xs <- buildChunks streamPtr action status return $! x:xs -- the input buffer points into a pinned bytestring, so we need to make sure it's been@@ -163,7 +180,8 @@ else fail $ "lzma_code failed: " ++ prettyRet ret -- nothing to do here- | otherwise = return []+ | otherwise =+ return [] getChunk :: Ptr C'lzma_stream@@ -179,5 +197,7 @@ -- B.pack* copies the buffer, so reuse it pokeNextOut streamPtr baseBuffer return bs- | otherwise = return B.empty++ | otherwise =+ return B.empty