I/O

The 'io' module provides functionality to interact with files

Function Signatures

// File open modes
const OpenMode = {
    app: 1,
    read: 8,
    write: 16,
    trunc: 32,
}

// Open a file with specified file path and open mode.
const open = (filePath: String, openMode: Number = OpenMode.read) => Pointer

// Close a file with given file handle.
const close = (fileHandle: Pointer) => None

// Read from a file with given file handle.
const read = (fileHandle: Pointer) => String

// Write content to a file with given file handle.
const write = (fileHandle: Pointer, content: String) => None

// Read input from standard input.
const input = () => String

// Read content from a file with specified file path. Automatically handles closing the file.
const readf = (filePath: String) => String

// Write content to a file with specified file path, truncating existing content. Automatically handles closing the file.
const writef = (filePath: String, content: String) => String

// Append content to a file with specified file path. Automatically handles closing the file.
const appendf = (filePath: String, content: String) => String

Last updated