The File system operation is used for file I/O functions in Cuneiform.
var file = new File;
The name property is a string value that contains the name of the file you want to access. You may also provide the path to the file that needs to be accessed.
The access mode determines the mode in which the file has to be opened, i.e., read, write, append, etc. A complete list of possible values is given below in the table.
Mode | Description |
r | Opens a file for reading only. The file pointer is placed at the beginning of the file. |
r+ | Opens the file for both reading and writing. The file pointer is placed at the beginning of the file. |
w | Opens a file for writing only. If the file exists, it gets overwritten. If the file does not exist, a new file is created for writing. |
w+ | Opens a file for both reading and writing. Overwrites the existing file if it exists. If the file does not exist, creates a new file for reading and writing. |
a | Opens a file for appending. If the file exists, the file pointer is at the end of the file. If the file does not exist, it creates a new file for writing. |
a+ | Opens a file for both appending and reading. If the file exists, the file pointer is at the end of the file. If the file does not exist, it creates a new file for reading and writing. |
The insert property must be provided only when writing, and appending to a file. The provided value is an array, where each element in the array represents a new line.
Writes provided text to the file as a single line. If multiple values are provided in the insert property, every value is written in the same line.
Returns 1 if written to file successfully, returns 0 otherwise.
Writes provided text in multiple lines, where each value in the insert property is written in a new line.
Returns 1 if written to file successfully, returns 0 otherwise.
Reads the entire text in the file as a whole.
Returns the text file as a single string value.
Reads the text in the file line by line.
Returns the text file as an array of strings, where each element in the array represents the text in a line.
The next part discusses the implementation of the InternalDatabase system operation.