Quirrel4.41.0

io

File access.

from "io" import ...

Values

stderrstderrThe process's standard error stream, already open as an io.file instance.
stdinstdinThe process's standard input stream, already open as an io.file instance.
stdoutstdoutThe process's standard output stream, already open as an io.file instance.

file class

An open file.

Functions

closeinstance.close()Closes the file if it is still open
constructorconstructor(path: string|userpointer, mode: string|int|null): instanceTwo 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
eosinstance.eos(): int|nullReturns non-null if the stream is at end-of-stream
flushinstance.flush(): int|nullFlushes the stream and returns non-null on success
leninstance.len(): intReturns the stream length
readblobinstance.readblob(size: int): instanceReads up to size bytes and returns them as a blob
readninstance.readn(format: int): numberReads a value of the given numeric format and returns it
readobjectinstance.readobject([classes: table|null]): anyDeserializes an object from the stream
seekinstance.seek(offset: int, [origin: int]): intSeeks to the given offset; origin is 'b' (begin), 'c' (current) or 'e' (end)
tellinstance.tell(): intReturns the current stream position
writeblobinstance.writeblob(blob: instance): intWrites the given blob and returns the number of bytes written
writeninstance.writen(value: number, format: int)Writes a numeric value in the given format
writeobjectinstance.writeobject(obj, [classes: table|null])Serializes the object to the stream
writestringinstance.writestring(str: string): intWrites the string and returns the number of characters written