Lynxer

Documentation

fileIO

File reading, writing, copying, moving and metadata helpers.

Backend: native — stdlib/fileIO.so, built from stdlib/fileIO.cpp over <fstream> and <filesystem>. Import: import("fileIO") → global.fileIO.*

Functions return "", false or -1 on error.

FunctionSignatureNotes
readFile(str path) -> strEntire file as UTF-8 text, or ""
writeFile(str path, str content) -> boolOverwrites
appendFile(str path, str content) -> boolAppends
fileExists(str path) -> boolTrue for a regular file
deleteFile(str path) -> boolRemoves the file
readLines(str path) -> listContent split on newlines; empty list on error
copyFile(str src, str dst) -> boolOverwrites dst
moveFile(str src, str dst) -> boolRenames or moves
fileSize(str path) -> intBytes, or -1
countLines(str path) -> intLine count, or -1
readLine(str path, int n) -> str0-based line, or ""
fileModTime(str path) -> strYYYY-MM-DD HH:MM:SS local time, or ""
fileExtension(str path) -> strExtension including the dot, or ""
fileIsEmpty(str path) -> boolTrue for an existing zero-byte file
tempFile(str suffix) -> strCreates a temporary file and returns its path
tempDir() -> strCreates a temporary directory and returns its path
stemName(str path) -> strFilename without directory or extension
readFileLines(str path, str sep) -> strLines joined with sep

readLines splits the raw file content on \n, so a file that ends with a newline produces a trailing empty element — by design.

Example

global setup(){ import("fileIO"); }

global main(){
    global.fileIO.writeFile("/tmp/notes.txt", "alpha\nbeta\n");
    println(global.fileIO.readLines("/tmp/notes.txt"));
    println(global.fileIO.countLines("/tmp/notes.txt"));
    println(global.fileIO.readFileLines("/tmp/notes.txt", " | "));
}

See also