io
File access.
from "io" import ...
Values
| stderr | stderr | The process's standard error stream, already open as an io.file instance. |
| stdin | stdin | The process's standard input stream, already open as an io.file instance. |
| stdout | stdout | The process's standard output stream, already open as an io.file instance. |
file class
An open file.
Functions
| close | instance.close() | Closes the file if it is still open |
| constructor | constructor(path: string|userpointer, mode: string|int|null): instance | Two forms: (path: string, mode: string) opens the file via fopen with the given mode; (handle: userpointer, own) wraps an existing FILE* and takes ownership (closes on destruction) when own is non-null, or shares it without closing when own is null |
| eos | instance.eos(): int|null | Returns non-null if the stream is at end-of-stream |
| flush | instance.flush(): int|null | Flushes the stream and returns non-null on success |
| len | instance.len(): int | Returns the stream length |
| readblob | instance.readblob(size: int): instance | Reads up to size bytes and returns them as a blob |
| readn | instance.readn(format: int): number | Reads a value of the given numeric format and returns it |
| readobject | instance.readobject([classes: table|null]): any | Deserializes an object from the stream |
| seek | instance.seek(offset: int, [origin: int]): int | Seeks to the given offset; origin is 'b' (begin), 'c' (current) or 'e' (end) |
| tell | instance.tell(): int | Returns the current stream position |
| writeblob | instance.writeblob(blob: instance): int | Writes the given blob and returns the number of bytes written |
| writen | instance.writen(value: number, format: int) | Writes a numeric value in the given format |
| writeobject | instance.writeobject(obj, [classes: table|null]) | Serializes the object to the stream |
| writestring | instance.writestring(str: string): int | Writes the string and returns the number of characters written |