2020-05-18 15:59:07 +03:00
|
|
|
module System.File
|
|
|
|
|
2021-08-30 17:31:37 +03:00
|
|
|
import Data.Buffer
|
|
|
|
|
|
|
|
import public System.File.Buffer
|
|
|
|
import public System.File.Error
|
|
|
|
import public System.File.Handle
|
|
|
|
import public System.File.Meta
|
|
|
|
import public System.File.Mode
|
|
|
|
import public System.File.Permissions
|
|
|
|
import public System.File.Process
|
|
|
|
import public System.File.ReadWrite
|
|
|
|
import public System.File.Types
|
|
|
|
import public System.File.Virtual
|
|
|
|
|
2021-10-29 19:58:29 +03:00
|
|
|
||| Copy the file at the specified source to the given destination.
|
2022-01-25 16:25:06 +03:00
|
|
|
||| Returns the number of bytes that have been written upon a write error.
|
2021-10-29 19:58:29 +03:00
|
|
|
|||
|
|
|
|
||| @ src the file to copy
|
|
|
|
||| @ dest the place to copy the file to
|
2021-08-30 17:31:37 +03:00
|
|
|
export
|
2022-01-25 16:25:06 +03:00
|
|
|
copyFile : HasIO io => (src : String) -> (dest : String) -> io (Either (FileError, Int) ())
|
2021-08-30 17:31:37 +03:00
|
|
|
copyFile src dest
|
|
|
|
= do Right buf <- createBufferFromFile src
|
2022-01-25 16:25:06 +03:00
|
|
|
| Left err => pure (Left (err, 0))
|
2021-08-30 17:31:37 +03:00
|
|
|
writeBufferToFile dest buf !(rawSize buf)
|