File
Contains common operations for File input & output.
Functions
All the current functions of the File module.
open(path: string, mode: string)
Opens a file and returns a file object.
Taking the path & mode arguments into account, so incase of failure a runtime error will occur.
File.open("someFile.txt", "w");
//new file object for writing.
write(file: object, content: string)
Writes the content string argument to the given write-able file. Returns the number of characters written.
File.write(myFile, "Hello world!"); //12
read(file: object)
Reads the entire content of the given read-able file and returns it as a string.
File.read(myFile); //"Hello world!"
isEOF(file: object)
Returns a boolean whether the end-of-file flag is set for the given file.
File.isEOF(myFile); //false
seek(file: object, offset: number, mode: number)
Changes the given file's position to the given coordinates (offset, mode).
//Start of the file
File.seek(myFile, 0, 0);
exists(path: string)
Returns a boolean whether a file exists at the given path.
File.exists("someFile.txt"); //true
close(file: object)
Closes the given file.
File.close(myFile);
Properties
All the current properties of the File module.
Seeking Modes
Properties for file seeking modes.
File.SEEK_SET; //start of file
File.SEEK_CUR; //current position
File.SEEK_END; //end of file
Standard IO Files
Represents file objects for standard input, output and error.
File.stdout; //output
File.stdin; //input
File.stderr; //error