summaryrefslogtreecommitdiff
path: root/src/Codec/Archive/Unpack.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Codec/Archive/Unpack.hs')
-rw-r--r--src/Codec/Archive/Unpack.hs25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/Codec/Archive/Unpack.hs b/src/Codec/Archive/Unpack.hs
index 937b1cc..0f10b26 100644
--- a/src/Codec/Archive/Unpack.hs
+++ b/src/Codec/Archive/Unpack.hs
@@ -45,13 +45,14 @@ bsToArchive bs = do
--
-- @since 1.0.0.0
readArchiveFile :: FilePath -> ArchiveM [Entry]
-readArchiveFile fp = actFree archiveReadNew (\a -> archiveFile fp a *> hsEntries a)
--- actFree hsEntries <=< a dorchiveFile
+readArchiveFile = actFree hsEntries <=< archiveFile
-archiveFile :: FilePath -> Ptr Archive -> ArchiveM ()
-archiveFile fp a = withCStringArchiveM fp $ \cpath ->
- ignore (archiveReadSupportFormatAll a) *>
- handle (archiveReadOpenFilename a cpath 10240)
+archiveFile :: FilePath -> ArchiveM (Ptr Archive)
+archiveFile fp = withCStringArchiveM fp $ \cpath -> do
+ a <- liftIO archiveReadNew
+ ignore $ archiveReadSupportFormatAll a
+ handle $ archiveReadOpenFilename a cpath 10240
+ pure a
-- | This is more efficient than
--
@@ -61,13 +62,11 @@ archiveFile fp a = withCStringArchiveM fp $ \cpath ->
unpackArchive :: FilePath -- ^ Filepath pointing to archive
-> FilePath -- ^ Dirctory to unpack in
-> ArchiveM ()
-unpackArchive tarFp dirFp =
- bracketM
- archiveReadNew
- archiveFree
- (\a ->
- archiveFile tarFp a *>
- unpackEntriesFp a dirFp)
+unpackArchive tarFp dirFp = do
+ -- TODO: bracket here
+ a <- archiveFile tarFp
+ unpackEntriesFp a dirFp
+ ignore $ archiveFree a
readEntry :: Ptr Archive -> Ptr ArchiveEntry -> IO Entry
readEntry a entry =