Lastik 0.1 → 0.2
raw patch · 2 files changed
+22/−6 lines, 2 filesdep +SHAdep +pureMD5PVP ok
version bump matches the API change (PVP)
Dependencies added: SHA, pureMD5
API changes (from Hackage documentation)
+ Lastik.Directory: writeHashArchive :: [(FilePath, FilePath)] -> RecursionPredicate -> FilterPredicate -> [ZipOption] -> FilePath -> IO ()
Files
- Lastik.cabal +4/−4
- Lastik/Directory.hs +18/−2
Lastik.cabal view
@@ -1,8 +1,8 @@ Name: Lastik-Version: 0.1+Version: 0.2 License: BSD3 License-File: LICENSE-Author: Tony Morris <tmorris@tmorris.net>+Author: Tony Morris <code@tmorris.net> Maintainer: Tony Morris Synopsis: A library for compiling programs in a variety of languages Category: Development@@ -16,9 +16,9 @@ Library if flag(small_base)- Build-Depends: base < 4 && >= 3, bytestring, directory, filepath, process, FileManip, zip-archive+ Build-Depends: base < 4 && >= 3, bytestring, directory, filepath, process, FileManip, zip-archive, pureMD5, SHA else- Build-Depends: base < 3, filepath, process, FileManip, zip-archive+ Build-Depends: base < 3, filepath, process, FileManip, zip-archive, pureMD5, SHA GHC-Options: -Wall Exposed-Modules:
Lastik/Directory.hs view
@@ -3,6 +3,7 @@ chdir, archiveDirectories, writeArchive,+ writeHashArchive, copyDir, dropRoot, dropRoot',@@ -17,6 +18,8 @@ import qualified Data.ByteString.Lazy as B import Control.Monad import Control.Exception+import Data.Digest.Pure.MD5+import Data.Digest.Pure.SHA -- | Change to the given directory, then execute the given action, then change back to the original directory. chdir :: FilePath -- ^ The directory to change to.@@ -25,7 +28,7 @@ chdir d a = bracket getCurrentDirectory setCurrentDirectory (\_ -> setCurrentDirectory d >> a) -- | Create a zip archive by changing into directories and archiving the contents.-archiveDirectories :: [(FilePath, FilePath)] -- ^ A list of base directory to change to and contents of that directory to archive.+archiveDirectories :: [(FilePath, FilePath)] -- ^ A list of base directories to change to and contents of that directory to archive. -> RecursionPredicate -- ^ The recursion predicate to search for files to archive. -> FilterPredicate -- ^ The filter predicate to search for files to archive. -> [ZipOption] -- ^ The options during the creation of the archive.@@ -34,7 +37,7 @@ addFilesToArchive opts a j) emptyArchive dirs -- | Writes a zip archive to a file.-writeArchive :: [(FilePath, FilePath)] -- ^ A list of base directory to change to and contents of that directory to archive.+writeArchive :: [(FilePath, FilePath)] -- ^ A list of base directories to change to and contents of that directory to archive. -> RecursionPredicate -- ^ The recursion predicate to search for files to archive. -> FilterPredicate -- ^ The filter predicate to search for files to archive. -> [ZipOption] -- ^ The options during the creation of the archive.@@ -42,6 +45,19 @@ -> IO () writeArchive dirs rp fp opts f = do a <- archiveDirectories dirs rp fp opts B.writeFile f (fromArchive a)++-- | Writes a zip archive to a file then computes a MD5 and SHA1 hash and writes them to files with @".MD5"@ and @".SHA"@ extensions.+writeHashArchive :: [(FilePath, FilePath)] -- ^ A list of base directories to change to and contents of that directory to archive.+ -> RecursionPredicate -- ^ The recursion predicate to search for files to archive.+ -> FilterPredicate -- ^ The filter predicate to search for files to archive.+ -> [ZipOption] -- ^ The options during the creation of the archive.+ -> FilePath -- ^ The file to write the archive to and the prefix name of the files containing the hashes.+ -> IO ()+writeHashArchive dirs rp fp opts f = do a <- archiveDirectories dirs rp fp opts+ let s = fromArchive a+ B.writeFile f s+ writeFile (f <.> "MD5") (show (md5 s))+ writeFile (f <.> "SHA") (show (sha1 s)) -- | Copy the contents of a directory to another, perhaps trimming parent directories. copyDir :: RecursionPredicate -- ^ The recursion predicate to search for files in the source directory.