IdrisDoc: Prelude.File

Prelude.File

data Directory : Type

A directory handle

DHandle : (p : Ptr) -> Directory
data File : Type

A file handle

FHandle : (p : Ptr) -> File
data FileError : Type

An error from a file operation

GenericFileError : Int -> FileError
FileReadError : FileError
FileWriteError : FileError
FileNotFound : FileError
PermissionDenied : FileError
data Mode : Type

Modes for opening files

Read : Mode
WriteTruncate : Mode
Append : Mode
ReadWrite : Mode
ReadWriteTruncate : Mode
ReadAppend : Mode
changeDir : String -> IO Bool
closeFile : File -> IO ()
createDir : String -> IO (Either FileError ())
currentDir : IO String
dirClose : Directory -> IO ()
dirEntry : Directory -> IO (Either FileError String)
dirError : Directory -> IO Bool
dirOpen : (d : String) -> IO (Either FileError Directory)
fEOF : File -> IO Bool

Check if a file handle has reached the end

fGetChars : (h : File) -> (len : Int) -> IO (Either FileError String)

Read up to a number of characters from a file

h

a file handle which must be open for reading

fGetLine : (h : File) -> IO (Either FileError String)

Read a line from a file

h

a file handle which must be open for reading

fPutStr : (h : File) -> (str : String) -> IO (Either FileError ())

Write a line to a file

h

a file handle which must be open for writing

str

the line to write to the file

fPutStrLn : File -> String -> IO (Either FileError ())
ferror : File -> IO Bool
fflush : File -> IO ()
fgetc : File -> IO (Either FileError Char)
fileAccessTime : File -> IO (Either FileError Integer)
fileModifiedTime : File -> IO (Either FileError Integer)
fileSize : File -> IO (Either FileError Int)

Return the size of a File
Returns an error if the File is not an ordinary file (e.g. a directory)
Also note that this currently returns an Int, which may overflow if the
file is very big

fileStatusTime : File -> IO (Either FileError Integer)
fopen : (f : String) -> (m : String) -> IO (Either FileError File)

Open a file

f

the filename

m

the mode as a String ("r", "w", or "r+")

fpoll : File -> IO Bool
getFileError : IO FileError
modeStr : Mode -> String
openFile : (f : String) -> (m : Mode) -> IO (Either FileError File)

Open a file

f

the filename

m

the mode; either Read, WriteTruncate, Append, ReadWrite, ReadWriteTruncate, or ReadAppend

openFileX : (f : String) -> (m : Mode) -> IO (Either FileError File)

Open a file using C11 extended modes.

f

the filename

m

the mode; either Read, WriteTruncate, Append, ReadWrite, ReadWriteTruncate, or ReadAppend

pclose : File -> IO ()
popen : String -> Mode -> IO (Either FileError File)
readFile : (filepath : String) -> IO (Either FileError String)

Read the contents of a text file into a string
This checks the size of the file before beginning to read, and only
reads that many bytes, to ensure that it remains a total function if
the file is appended to while being read.
This only works reliably with text files, since it relies on null-terminated
strings internally.
Returns an error if filepath is not a normal file.

stderr : File

Standard output

stdin : File

Standard input

stdout : File

Standard output

validFile : File -> IO Bool

Check whether a file handle is actually a null pointer

writeFile : (filepath : String) -> (contents : String) -> IO (Either FileError ())

Write a string to a file