Commits

Aleksey Khudyakov  committed d753944

More granular combinators

  • Participants
  • Parent commits ce88823

Comments (0)

Files changed (1)

 
 -- | Read compressed tarball
 readTar :: FilePath -> IO [Entry]
-readTar path = do
-  bs <- L.readFile path
-  return $ foldEntries (:) [] (error . show)
-         $ Tar.read
-         $ decompress bs
+readTar path = withFile path ReadMode hreadTar
+
+-- | Read compressed tarball from file handle
+hreadTar :: Handle -> IO [Entry]
+hreadTar h = unpackTar `fmap` L.hGetContents h
+
+unpackTar 
+  = foldEntries (:) [] (error . show)
+  . Tar.read
+  . decompress
 
 -- | Append file to the gzip compressed tarball
 appendToTar :: FilePath -> FilePath -> L.ByteString -> IO ()