mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-29 22:51:51 +03:00
20 lines
678 B
Idris
20 lines
678 B
Idris
module System.File.Mode
|
|
|
|
import System.Info
|
|
|
|
%default total
|
|
|
|
||| The different modes a file can be opened.
|
|
public export
|
|
data Mode = Read | WriteTruncate | Append | ReadWrite | ReadWriteTruncate | ReadAppend
|
|
|
|
||| Convert a file `Mode` to the OS-appropriate string representation.
|
|
export
|
|
modeStr : Mode -> String
|
|
modeStr Read = if isWindows then "rb" else "r"
|
|
modeStr WriteTruncate = if isWindows then "wb" else "w"
|
|
modeStr Append = if isWindows then "ab" else "a"
|
|
modeStr ReadWrite = if isWindows then "rb+" else "r+"
|
|
modeStr ReadWriteTruncate = if isWindows then "wb+" else "w+"
|
|
modeStr ReadAppend = if isWindows then "ab+" else "a+"
|