Commit acbf87c0 authored by Steffen Michels's avatar Steffen Michels

Merge branch '437-use-system-file-_copyfile-for-copying-files' into 'master'

use copyFile instead of manually copying in Extension.File

Closes #437

See merge request !536
parents 62f6b331 78c1defa
Pipeline #48201 failed with stages
in 6 minutes and 45 seconds
......@@ -30,28 +30,7 @@ moveFile :: !FilePath !FilePath -> Task ()
moveFile srcPath dstPath = accWorldError ('SF'.moveFile srcPath dstPath) (addExplanation ["Failed to move ",srcPath," to ",dstPath])
copyFile :: !FilePath !FilePath -> Task ()
copyFile srcPath dstPath = accWorldError (copyFile` srcPath dstPath) (\e -> concat ["Failed to copy ",srcPath," to ",dstPath,": ",e])
copyFile` :: !FilePath !FilePath !*World -> (MaybeError String (), !*World)
copyFile` srcPath dstPath w
# (ok, srcFile, w) = fopen srcPath FReadText w
| not ok = (Error ("cannot open " +++ srcPath), w)
# (ok, dstFile, w) = fopen dstPath FWriteText w
| not ok = (Error ("cannot open " +++ dstPath), w)
# (srcFile, dstFile) = actuallyCopy srcFile dstFile
# (ok, w) = fclose srcFile w
| not ok = (Error ("cannot close " +++ srcPath), w)
# (ok, w) = fclose dstFile w
| not ok = (Error ("cannot close " +++ dstPath), w)
= (Ok (), w)
where
actuallyCopy :: !*File !*File -> (!*File, !*File)
actuallyCopy src dst
# (end, src) = fend src
| end = (src, dst)
# (s, src) = freads src 65536
# dst = dst <<< s
= actuallyCopy src dst
copyFile srcPath dstPath = accWorldError ('SF'.copyFile srcPath dstPath) (\e -> concat ["Failed to copy ",srcPath," to ",dstPath,": ",e])
createDirectory :: !FilePath !Bool -> Task ()
createDirectory path False = accWorldError ('SD'.createDirectory path) (addExplanation ["Failed to create directory ",path])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment