The I/O library provides two different styles for file manipulation. The first one uses implicit file descriptors; that is, there are operations to set a default input file and a default output file, and all input/output operations are over these default files. The second style uses explicit file descriptors.
When using implicit file descriptors,
all operations are supplied by table io
.
When using explicit file descriptors,
the operation io.open
returns a file descriptor
and then all operations are supplied as methods of the file descriptor.
The table io
also provides
three predefined file descriptors with their usual meanings from C:
io.stdin
, io.stdout
, and io.stderr
.
Unless otherwise stated, all I/O functions return nil on failure (plus an error message as a second result) and some value different from nil on success.