LIB: add destination dir name argument to copyDir
This commit is contained in:
parent
0a71c3c044
commit
0d92ebb8c8
@ -165,15 +165,18 @@ runFileOp _ = return Nothing
|
|||||||
copyDir :: CopyMode
|
copyDir :: CopyMode
|
||||||
-> AnchoredFile FileInfo -- ^ source dir
|
-> AnchoredFile FileInfo -- ^ source dir
|
||||||
-> AnchoredFile FileInfo -- ^ destination dir
|
-> AnchoredFile FileInfo -- ^ destination dir
|
||||||
|
-> Path Fn -- ^ destination dir name
|
||||||
-> IO ()
|
-> IO ()
|
||||||
copyDir _ AFileInvFN _ = throw InvalidFileName
|
copyDir _ AFileInvFN _ _ = throw InvalidFileName
|
||||||
copyDir _ _ AFileInvFN = throw InvalidFileName
|
copyDir _ _ AFileInvFN _ = throw InvalidFileName
|
||||||
copyDir cm from@(_ :/ Dir fromn FileInfo{ fileMode = fmode })
|
copyDir _ _ _ InvFN = throw InvalidFileName
|
||||||
|
copyDir cm from@(_ :/ Dir _ FileInfo{ fileMode = fmode })
|
||||||
to@(_ :/ Dir {})
|
to@(_ :/ Dir {})
|
||||||
|
fn
|
||||||
= do
|
= do
|
||||||
let fromp = fullPath from
|
let fromp = fullPath from
|
||||||
top = fullPath to
|
top = fullPath to
|
||||||
destdirp = top P.</> fromn
|
destdirp = top P.</> fn
|
||||||
throwDestinationInSource fromp destdirp
|
throwDestinationInSource fromp destdirp
|
||||||
throwSameFile fromp destdirp
|
throwSameFile fromp destdirp
|
||||||
throwCantOpenDirectory fromp
|
throwCantOpenDirectory fromp
|
||||||
@ -187,7 +190,7 @@ copyDir cm from@(_ :/ Dir fromn FileInfo{ fileMode = fmode })
|
|||||||
for_ contents $ \f ->
|
for_ contents $ \f ->
|
||||||
case f of
|
case f of
|
||||||
(_ :/ SymLink {}) -> recreateSymlink cm f destdir (name . file $ f)
|
(_ :/ SymLink {}) -> recreateSymlink cm f destdir (name . file $ f)
|
||||||
(_ :/ Dir {}) -> copyDir cm f destdir
|
(_ :/ Dir {}) -> copyDir cm f destdir (name . file $ f)
|
||||||
(_ :/ RegFile {}) -> copyFile Replace f destdir (name . file $ f)
|
(_ :/ RegFile {}) -> copyFile Replace f destdir (name . file $ f)
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
where
|
where
|
||||||
@ -205,7 +208,7 @@ copyDir cm from@(_ :/ Dir fromn FileInfo{ fileMode = fmode })
|
|||||||
(deleteDirRecursive =<<
|
(deleteDirRecursive =<<
|
||||||
HSFM.FileSystem.FileType.readFileWithFileInfo destdir)
|
HSFM.FileSystem.FileType.readFileWithFileInfo destdir)
|
||||||
createDirectory destdir' fmode'
|
createDirectory destdir' fmode'
|
||||||
copyDir _ _ _ = throw $ InvalidOperation "wrong input type"
|
copyDir _ _ _ _ = throw $ InvalidOperation "wrong input type"
|
||||||
|
|
||||||
|
|
||||||
-- |Recreate a symlink.
|
-- |Recreate a symlink.
|
||||||
@ -303,7 +306,7 @@ easyCopy cm from@(_ :/ RegFile{})
|
|||||||
= copyFile cm from to (name . file $ from)
|
= copyFile cm from to (name . file $ from)
|
||||||
easyCopy cm from@(_ :/ Dir{})
|
easyCopy cm from@(_ :/ Dir{})
|
||||||
to@(_ :/ Dir{})
|
to@(_ :/ Dir{})
|
||||||
= copyDir cm from to
|
= copyDir cm from to (name . file $ from)
|
||||||
easyCopy _ _ _ = throw $ InvalidOperation "wrong input type"
|
easyCopy _ _ _ = throw $ InvalidOperation "wrong input type"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user