packages feed

archive-sig 0.1.0.0 → 0.2.0.0

raw patch · 6 files changed

+73/−29 lines, 6 filesdep −dlistPVP ok

version bump matches the API change (PVP)

Dependencies removed: dlist

API changes (from Hackage documentation)

- Archive: packFromFiles :: FilePath -> [FilePath] -> IO ()
+ Archive: packFiles :: [FilePath] -> IO ByteString
+ Archive.Compression: packFromDirAndCompress :: Compressor -> FilePath -> FilePath -> IO ()
+ Archive.Compression: packFromFilesAndCompress :: Compressor -> FilePath -> [FilePath] -> IO ()
+ Archive.Compression: type Decompressor = ByteString -> ByteString
+ Archive.Compression: unpackFileToDirAndDecompress :: Decompressor -> FilePath -> FilePath -> IO ()
+ Archive.Generic: packFromFiles :: FilePath -> [FilePath] -> IO ()

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# 0.2.0.0++  * Add `unpackFileToDirAndDecompress`+  * Move `packFromFiles` to `Archive.Generic` and add `packFiles`+  * Remove `dlist` dependency
archive-sig.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: archive-sig-version: 0.1.0.0+version: 0.2.0.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2019 Vanessa McHale@@ -11,6 +11,7 @@     Backpack signature that provide a common interface to the Haskell tar package and the Haskell libarchive bindings category: Codec, Tar, Archive build-type: Simple+extra-doc-files: CHANGELOG.md  source-repository head     type: git@@ -25,15 +26,17 @@ library     exposed-modules:         Archive.Generic+        Archive.Compression     signatures: Archive     hs-source-dirs: src+    other-modules:+        System.Directory.Recursive     default-language: Haskell2010     ghc-options: -Wall     build-depends:         base >=4.3 && <5,         bytestring -any,         directory -any,-        dlist -any,         bytestring -any,         composition-prelude >=2.0.3.0,         filepath -any
src/Archive.hsig view
@@ -2,9 +2,8 @@                   , Error                   , unpackToDir                   , readArchiveBytes-                  , packFromFiles+                  , packFiles                   , writeArchiveBytes-                  -- , mkEntry                   ) where  import qualified Data.ByteString.Lazy as BSL@@ -15,9 +14,9 @@  instance Show Error -packFromFiles :: FilePath -- ^ Path of @.tar@ file to write-              -> [FilePath] -- ^ Files and directories to archive-              -> IO ()+-- | @since 0.2.0.0+packFiles :: [FilePath] -- ^ Files and directories to write to archive+          -> IO BSL.ByteString -- ^ 'BSL.ByteString' containing archive  unpackToDir :: FilePath -> BSL.ByteString -> IO () 
+ src/Archive/Compression.hs view
@@ -0,0 +1,28 @@+module Archive.Compression ( Decompressor+                           , unpackFileToDirAndDecompress+                           , packFromFilesAndCompress+                           , packFromDirAndCompress+                           ) where++import           Archive+import qualified Data.ByteString.Lazy       as BSL+import           Data.Foldable              (toList)+import           System.Directory.Recursive++type Decompressor = BSL.ByteString -> BSL.ByteString+type Compressor = BSL.ByteString -> BSL.ByteString++-- | @since 0.2.0.0+unpackFileToDirAndDecompress :: Decompressor -- ^ Decompression to use+                             -> FilePath -- ^ Filepath pointing to archive+                             -> FilePath -- ^ Directory+                             -> IO ()+unpackFileToDirAndDecompress f tar dir = unpackToDir dir =<< (f <$> BSL.readFile tar)++-- | @since 0.2.0.0+packFromDirAndCompress :: Compressor -> FilePath -> FilePath -> IO ()+packFromDirAndCompress f dir tar = packFromFilesAndCompress f tar =<< fmap toList (getDirRecursive dir)++-- | @since 0.2.0.0+packFromFilesAndCompress :: Compressor -> FilePath -> [FilePath] -> IO ()+packFromFilesAndCompress f tar fps = BSL.writeFile tar =<< (f <$> packFiles fps)
src/Archive/Generic.hs view
@@ -2,17 +2,19 @@                        , unpackFileToDir                        , unpackFromFile                        , packToFile+                       , packFromFiles                        ) where  import           Archive-import           Control.Composition  ((.*), (.@))-import           Control.Monad        (filterM)+import           Archive.Compression+import           Control.Composition  ((.@)) import qualified Data.ByteString.Lazy as BSL-import           Data.DList           (DList, fromList)-import           Data.Foldable        (fold, toList)-import           System.Directory     (doesDirectoryExist, getDirectoryContents)-import           System.FilePath      ((</>)) +packFromFiles :: FilePath -- ^ Path of @.tar@ file to write+              -> [FilePath] -- ^ Files and directories to archive+              -> IO ()+packFromFiles = packFromFilesAndCompress id+ packToFile :: FilePath -> [Entry] -> IO () packToFile = writeArchiveBytes .@ BSL.writeFile @@ -22,23 +24,9 @@ unpackFileToDir :: FilePath -- ^ Filepath pointing to archive                 -> FilePath -- ^ Directory                 -> IO ()-unpackFileToDir tar dir = unpackToDir dir =<< BSL.readFile tar+unpackFileToDir = unpackFileToDirAndDecompress id  packFromDir :: FilePath -- ^ Directory to be packed up             -> FilePath -- ^ @.tar@ archive file             -> IO ()-packFromDir dir tar = packFromFiles tar =<< fmap toList (getDirRecursive dir)--getDirRecursive :: FilePath -> IO (DList FilePath)-getDirRecursive fp = do-    all' <- exclude <$> getDirectoryContents fp-    dirs <- exclude <$> filterM doesDirectoryExist (mkRel <$> all')-    case dirs of-        [] -> pure $ fromList (mkRel <$> all')-        ds -> do-            next <- foldMapA getDirRecursive ds-            pure $ next <> fromList (mkRel <$> all')--    where foldMapA = fmap fold .* traverse-          exclude = filter (\x -> x /= "." && x /= "..")-          mkRel = (fp </>)+packFromDir = packFromDirAndCompress id
+ src/System/Directory/Recursive.hs view
@@ -0,0 +1,21 @@+module System.Directory.Recursive ( getDirRecursive ) where++import           Control.Composition ((.*))+import           Control.Monad       (filterM)+import           Data.Foldable       (fold)+import           System.Directory    (doesDirectoryExist, getDirectoryContents)+import           System.FilePath     ((</>))++getDirRecursive :: FilePath -> IO [FilePath]+getDirRecursive fp = do+    all' <- exclude <$> getDirectoryContents fp+    dirs <- exclude <$> filterM doesDirectoryExist (mkRel <$> all')+    case dirs of+        [] -> pure (mkRel <$> all')+        ds -> do+            next <- foldMapA getDirRecursive ds+            pure $ next <> (mkRel <$> all')++    where foldMapA = fmap fold .* traverse+          exclude = filter (\x -> x /= "." && x /= "..")+          mkRel = (fp </>)