Lastik 0.3 → 0.4
raw patch · 2 files changed
+26/−3 lines, 2 filesdep −FileManipPVP ok
version bump matches the API change (PVP)
Dependencies removed: FileManip
API changes (from Hackage documentation)
+ Lastik.Directory: copyFiles :: RecursePredicate -> FilterPredicate -> FilePath -> FilePath -> IO ()
Files
- Lastik.cabal +2/−2
- Lastik/Directory.hs +24/−1
Lastik.cabal view
@@ -1,5 +1,5 @@ Name: Lastik-Version: 0.3+Version: 0.4 License: BSD3 License-File: LICENSE Author: Tony Morris <code@tmorris.net>@@ -18,7 +18,7 @@ if flag(small_base) Build-Depends: base < 4 && >= 3, bytestring, directory, filepath, process, zip-archive, pureMD5, SHA else- Build-Depends: base < 3, filepath, process, FileManip, zip-archive, pureMD5, SHA+ Build-Depends: base < 3, filepath, process, zip-archive, pureMD5, SHA GHC-Options: -Wall Exposed-Modules:
Lastik/Directory.hs view
@@ -8,7 +8,8 @@ dropRoot, dropRoot', mkdir,- rmdir+ rmdir,+ copyFiles ) where import System.Directory@@ -102,3 +103,25 @@ rmdir :: FilePath -- ^ The directory to remove. -> IO () rmdir d = doesDirectoryExist d >>= flip when (removeDirectoryRecursive d)++-- | Copies files from one directory to another directory.+copyFiles :: RecursePredicate -- ^ The recursion predicate to search for files to copy.+ -> FilterPredicate -- ^ The filter predicate to search for files to copy.+ -> FilePath -- ^ The directory to copy from.+ -> FilePath -- ^ The directory to copy to.+ -> IO ()+copyFiles r f from to = do isf <- doesFileExist from+ if isf+ then error ("Cannot copy from file " ++ from)+ else do isd <- doesDirectoryExist from+ if isd+ then do dis <- doesFileExist to+ if dis+ then error ("Cannot copy to" ++ to ++ " (a file)")+ else do j <- find r f from+ k <- filterM doesFileExist j+ mkdir to+ mapM_ (\z -> let t = to </> dropWhile (pathSeparator ==) (drop (length from) z)+ in do mkdir (dropFileName t)+ copyFile z t) k+ else error (from ++ " is not a directory")