0 | module System.File.Mode
 1 |
 2 | import System.Info
 3 |
 4 | %default total
 5 |
 6 | ||| The different modes a file can be opened.
 7 | public export
 8 | data Mode = Read | WriteTruncate | Append | ReadWrite | ReadWriteTruncate | ReadAppend
 9 |
10 | ||| Convert a file `Mode` to the OS-appropriate string representation.
11 | export
12 | modeStr : Mode -> String
13 | modeStr Read              = if isWindows then "rb" else "r"
14 | modeStr WriteTruncate     = if isWindows then "wb" else "w"
15 | modeStr Append            = if isWindows then "ab" else "a"
16 | modeStr ReadWrite         = if isWindows then "rb+" else "r+"
17 | modeStr ReadWriteTruncate = if isWindows then "wb+" else "w+"
18 | modeStr ReadAppend        = if isWindows then "ab+" else "a+"
19 |