packages feed

ztar 0.0.1 → 0.0.2

raw patch · 4 files changed

+30/−9 lines, 4 files

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# ztar 0.0.2++* Add createGZ'+ # ztar 0.0.1  * Initial commit
src/Codec/Archive/Tar/GZip.hs view
@@ -7,28 +7,45 @@ Functions to create/extract compressed tar archives. -} -module Codec.Archive.Tar.GZip (createGZ, extractGZ) where+module Codec.Archive.Tar.GZip (createGZ, createGZ', extractGZ) where  import qualified Codec.Archive.Tar as Tar import qualified Codec.Compression.GZip as GZ import qualified Data.ByteString.Lazy as BS --- | Create a new @.tar@ file from a directory of files.+-- | Create a new @.tar@ file from the given directory. -- -- It is equivalent to calling the standard 'tar' program like so: ----- @$ tar -f tarball.tar -C base -c dir -z@+-- @$ tar -czf tarball.tar -C dir .@ -- -- See 'Tar.create' for more details.-createGZ :: FilePath -> FilePath -> [FilePath] -> IO ()-createGZ tar base paths = BS.writeFile tar . GZ.compress . Tar.write =<< Tar.pack base paths+createGZ :: FilePath -- ^ tar archive+         -> FilePath -- ^ directory to archive+         -> IO ()+createGZ tar dir = createGZ' tar dir ["."] +-- | Create a new @.tar@ file from the given paths.+--+-- It is equivalent to calling the standard 'tar' program like so:+--+-- @$ tar -czf tarball.tar -C base paths@+--+-- See 'Tar.create' for more details.+createGZ' :: FilePath -- ^ tar archive+          -> FilePath -- ^ base directory+          -> [FilePath] -- ^ files and paths to compress, relative to base directory+          -> IO ()+createGZ' tar base paths = BS.writeFile tar . GZ.compress . Tar.write =<< Tar.pack base paths+ -- | Extract all the files contained in a @.tar@ file. -- -- It is equivalent to calling the standard 'tar' program like so: ----- @$ tar -x -f tarball.tar -C dir -z@+-- @$ tar -xzf tarball.tar -C dir@ -- -- See 'Tar.extract' for more details.-extractGZ :: FilePath -> FilePath -> IO ()+extractGZ :: FilePath -- ^ destination directory+          -> FilePath -- ^ tar archive+          -> IO () extractGZ dir tar = Tar.unpack dir . Tar.read . GZ.decompress =<< BS.readFile tar
test/Example.hs view
@@ -8,7 +8,7 @@ main :: IO () main = withSystemTempDir "" $ \dir -> do   mapM_ (mkFile dir) files-  createGZ (fromRelFile archive) (fromAbsDir dir) ["."]+  createGZ (fromRelFile archive) $ fromAbsDir dir    extractGZ (fromRelDir extractDir) $ fromRelFile archive   contents <- mapM (readFile . fromRelFile . (extractDir </>)) files
ztar.cabal view
@@ -1,5 +1,5 @@ name:                ztar-version:             0.0.1+version:             0.0.2 license:             BSD3 license-file:        LICENSE.md author:              Brandon Chinn <brandonchinn178@gmail.com>