ref: 46879fde32f83a510e87072fe59a6997f4265e30
parent: 14144a6a307102bbe2eb9841a3988bec5407dbc1
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Thu Mar 28 06:00:07 EDT 2024
Add copyFile
--- a/lib/System/Directory.hs
+++ b/lib/System/Directory.hs
@@ -7,6 +7,7 @@
setCurrentDirectory,
createDirectory,
createDirectoryIfMissing,
+ copyFile,
) where
import Prelude
import Control.Monad(when)
@@ -89,3 +90,12 @@
split r ('/':cs) = r : split [] cssplit r (c:cs) = split (r ++ [c]) cs
mapM_ (createDirectoryIfMissing False) ds
+
+-- XXX does not copy flags
+copyFile :: FilePath -> FilePath -> IO ()
+copyFile src dst = do
+ hsrc <- openBinaryFile src ReadMode
+ hdst <- openBinaryFile dst WriteMode
+ file <- hGetContents hsrc -- this also closes the file
+ hPutStr hdst file
+ hClose hdst
--
⑨