packages feed

libarchive 1.0.2.0 → 1.0.3.0

raw patch · 7 files changed

+23/−18 lines, 7 files

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # libarchive +## 1.0.3.0++  * Fix types for `archive_set_read_callback` and+    `archive_read_set_seek_callback`  ## 1.0.2.0 
libarchive.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: libarchive-version: 1.0.2.0+version: 1.0.3.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018-2019 Vanessa McHale
src/Codec/Archive.hs view
@@ -20,6 +20,7 @@     , Permissions     , ModTime     , Id+    -- * Permissions helpers     , standardPermissions     , executablePermissions     ) where@@ -28,30 +29,26 @@ import           Codec.Archive.Pack import           Codec.Archive.Types import           Codec.Archive.Unpack-import           Control.Monad         (void)+import           Control.Monad         (void, (<=<)) import           Data.ByteString       (useAsCStringLen) import qualified Data.ByteString       as BS import           Foreign.C.String import           Foreign.Ptr           (Ptr) import           System.IO.Unsafe      (unsafePerformIO) -withArchiveRead :: (Ptr Archive -> IO a) -> Ptr Archive -> IO a-withArchiveRead fact a = do-    res <- fact a-    void $ archive_read_free a-    pure res+-- | Read from an 'Archive' and then free it+actFree :: (Ptr Archive -> IO a) -> Ptr Archive -> IO a+actFree fact a = fact a <* archive_read_free a  -- | Read an archive from a file. The format of the archive is automatically -- detected. readArchiveFile :: FilePath -> IO [Entry]-readArchiveFile fp =-    archiveFile fp >>= withArchiveRead hsEntries+readArchiveFile = actFree hsEntries <=< archiveFile  -- | Read an archive contained in a 'BS.ByteString'. The format of the archive is -- automatically detected. readArchiveBS :: BS.ByteString -> [Entry]-readArchiveBS bs = unsafePerformIO $-    bsToArchive bs >>= withArchiveRead hsEntries+readArchiveBS = unsafePerformIO . (actFree hsEntries <=< bsToArchive) {-# NOINLINE readArchiveBS #-}  archiveFile :: FilePath -> IO (Ptr Archive)
src/Codec/Archive/Foreign.hs view
@@ -1,9 +1,10 @@ -- | Everything here is stateful and hence takes place in the 'IO' monad. ----- Consult @archive.h@ or @archive_entry.h@ for documentation.+-- Consult @archive.h@ or @archive_entry.h@ for documentation. Functions that+-- are deprecated in the C API are not exposed here at all. module Codec.Archive.Foreign ( module Codec.Archive.Foreign.ArchiveEntry                              , module Codec.Archive.Foreign.Archive                              ) where -import Codec.Archive.Foreign.ArchiveEntry-import Codec.Archive.Foreign.Archive+import           Codec.Archive.Foreign.Archive+import           Codec.Archive.Foreign.ArchiveEntry
src/Codec/Archive/Foreign/Archive.chs view
@@ -431,8 +431,8 @@ foreign import ccall unsafe archive_read_append_filter_program :: Ptr Archive -> CString -> IO ArchiveError foreign import ccall unsafe archive_read_append_filter_program_signature :: Ptr Archive -> CString -> Ptr a -> CSize -> IO ArchiveError foreign import ccall unsafe archive_read_set_open_callback :: Ptr Archive -> FunPtr (ArchiveOpenCallback a) -> IO ArchiveError-foreign import ccall unsafe archive_read_set_read_callback :: Ptr Archive -> FunPtr (ArchiveOpenCallback a) -> IO ArchiveError-foreign import ccall unsafe archive_read_set_seek_callback :: Ptr Archive -> FunPtr (ArchiveOpenCallback a) -> IO ArchiveError+foreign import ccall unsafe archive_read_set_read_callback :: Ptr Archive -> FunPtr (ArchiveReadCallback a b) -> IO ArchiveError+foreign import ccall unsafe archive_read_set_seek_callback :: Ptr Archive -> FunPtr (ArchiveSeekCallback a) -> IO ArchiveError foreign import ccall unsafe archive_read_set_skip_callback :: Ptr Archive -> FunPtr (ArchiveSkipCallback a) -> IO ArchiveError foreign import ccall unsafe archive_read_set_close_callback :: Ptr Archive -> FunPtr (ArchiveCloseCallback a) -> IO ArchiveError foreign import ccall unsafe archive_read_set_switch_callback :: Ptr Archive -> FunPtr (ArchiveSwitchCallback a b) -> IO ArchiveError
src/Codec/Archive/Pack.hs view
@@ -1,5 +1,4 @@-module Codec.Archive.Pack ( packEntries-                          , entriesToFile+module Codec.Archive.Pack ( entriesToFile                           , entriesToFileZip                           , entriesToFile7Zip                           , entriesToBS@@ -76,6 +75,7 @@ entriesToBSzip = unsafePerformIO . entriesToBSGeneral archive_write_set_format_zip {-# NOINLINE entriesToBSzip #-} +-- | Internal function to be used with 'archive_write_set_format_pax' etc. entriesToBSGeneral :: (Foldable t) => (Ptr Archive -> IO ArchiveError) -> t Entry -> IO BS.ByteString entriesToBSGeneral modifier hsEntries' = do     a <- archive_write_new
src/Codec/Archive/Unpack.hs view
@@ -21,6 +21,7 @@         <*> readOwnership entry         <*> readTimes entry +-- | Yield the next entry in an archive getHsEntry :: Ptr Archive -> IO (Maybe Entry) getHsEntry a = do     entry <- getEntry a@@ -28,6 +29,7 @@         Nothing -> pure Nothing         Just x  -> Just <$> readEntry a x +-- | Return a list of 'Entry's. hsEntries :: Ptr Archive -> IO [Entry] hsEntries a = do     next <- getHsEntry a@@ -78,6 +80,7 @@ readTimes entry =     (,) <$> archive_entry_mtime entry <*> archive_entry_mtime_nsec entry +-- | Get the next 'ArchiveEntry' in an 'Archive' getEntry :: Ptr Archive -> IO (Maybe (Ptr ArchiveEntry)) getEntry a = alloca $ \ptr -> do     let done res = not (res == archiveOk || res == archiveRetry)