LIB: make moveFile portable
This commit is contained in:
parent
35e6f5df82
commit
27673b0751
@ -35,7 +35,9 @@ import Control.Applicative
|
|||||||
)
|
)
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
(
|
(
|
||||||
throw
|
handle
|
||||||
|
, throw
|
||||||
|
, SomeException(..)
|
||||||
)
|
)
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
(
|
(
|
||||||
@ -396,7 +398,6 @@ renameFile af (ValFN fn) = do
|
|||||||
renameFile _ _ = return ()
|
renameFile _ _ = return ()
|
||||||
|
|
||||||
|
|
||||||
-- TODO: this is not portable for cross-device links!
|
|
||||||
-- |Move a given file to the given target directory.
|
-- |Move a given file to the given target directory.
|
||||||
moveFile :: AnchoredFile FileInfo -- ^ file to move
|
moveFile :: AnchoredFile FileInfo -- ^ file to move
|
||||||
-> AnchoredFile FileInfo -- ^ base target directory
|
-> AnchoredFile FileInfo -- ^ base target directory
|
||||||
@ -406,7 +407,10 @@ moveFile from to@(_ :/ Dir {}) = do
|
|||||||
to' = fullPath to </> (name . file $ from)
|
to' = fullPath to </> (name . file $ from)
|
||||||
throwFileDoesExist to'
|
throwFileDoesExist to'
|
||||||
throwSameFile from' to'
|
throwSameFile from' to'
|
||||||
rename from' to'
|
handle (\(SomeException e) -> do
|
||||||
|
easyCopy Strict from to
|
||||||
|
easyDelete from
|
||||||
|
) $ rename from' to'
|
||||||
moveFile _ _ = return ()
|
moveFile _ _ = return ()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user