File()
create :: File()
Creates an empty file object
Returns:
An empty File object
deleteFile(path)
deleteFile :: bool(path : string)
Deletes the file at the given path. Returns true on success.
#import Builtin.File;
File I/O - open, read, write, and close files on disk. Wraps the C standard library file functions.
Example:
#import Builtin.File; f : File = File("hello.txt", "w"); writeLine(f, "Hello, world!"); close(f); g : File = File(); g.open("hello.txt", "r"); contents : string = readAll(g); close(g);
create :: File()
Creates an empty file object
An empty File object
deleteFile :: bool(path : string)
Deletes the file at the given path. Returns true on success.
A handle to an open file on disk.
open :: File(path : const string, mode : const string)
Opens a file and returns a File handle. Mode follows C conventions: "r" (read), "w" (write/create), "a" (append), "r+" (read+write), "w+" (create+read+write). Check .isOpen to confirm the file opened successfully.
close :: ()
Closes the file and releases the handle.
readAll :: string()
Reads the entire contents of the file and returns it as a string.
readLine :: string()
Reads one line from the file (up to 4095 characters). Returns an empty string at end of file.
atEnd :: bool()
Returns true if the file position is at end of file.
write :: (s : string)
Writes a string to the file.
writeLine :: (s : string)
Writes a string followed by a newline to the file.