LIB: implement copyDir and minor refactor

We also had to lock the FileOperation type to DTInfoZipper so
we can examine symlinks and other stuff, without re-reading
all the information.
This commit is contained in:
2015-12-18 04:22:13 +01:00
parent 0781cbf9d5
commit d4a5460128
3 changed files with 81 additions and 17 deletions

View File

@@ -11,6 +11,10 @@ import Control.Monad
, void
, when
)
import Data.List
(
isPrefixOf
)
import Data.Typeable
import System.Directory
(
@@ -31,6 +35,7 @@ data FmIOException = FileDoesNotExist String
| SameFile String String
| NotAFile String
| NotADir String
| DestinationInSource String String
deriving (Show, Typeable)
@@ -79,3 +84,10 @@ throwSameFile :: FilePath -- ^ should be canonicalized
-> FilePath -- ^ should be canonicalized
-> IO ()
throwSameFile fp1 fp2 = when (equalFilePath fp1 fp2) (throw $ SameFile fp1 fp2)
throwDestinationInSource :: FilePath -- ^ should be canonicalized
-> FilePath -- ^ should be canonicalized
-> IO ()
throwDestinationInSource source dest =
when (source `isPrefixOf` dest) (throw $ DestinationInSource dest source)