File
In the prelude: every iyi program has it, with no import.
Fileclass
class File
def self.delete(path : String) : Nil
def self.exists?(path : String) : Bool
# Crystal's mode strings: "r", "w", "a", each with a "+" that adds the
# other direction, and a "b" anywhere after the letter that changes
# nothing, as POSIX has no text mode. "a" is the kernel's append - every
# write lands at the end whatever the position says, so two writers
# appending to one log do not overwrite each other - and not a seek to
# the end at open. *perm* is the mode a file the open creates gets, less
# the umask; a file already there keeps its own. *buffer_size* stays
# third so the callers that pass it by position keep working.
#
# One stream reads and writes through two buffers, so between a read and
# a write in "r+" or "w+" move with `seek` (std/file), as C's stdio asks
# of `fopen`'s "+" modes: a write after a read otherwise lands past the
# read-ahead, and a read after a write misses what is still buffered.
def self.open(path : String, mode : String = "r", buffer_size : Int32 = 4096, perm : Int32 = 420) : IyiIO
def self.open(path : String, mode : String = "r", buffer_size : Int32 = 4096, perm : Int32 = 420, & : (IyiIO -> Nil)) : Nil
def self.read(path : String) : String
def self.write(path : String, contents : String) : Nil
end