Io
package lua
Available on lua
Input and Output Facilities
Static variables
staticstderr:FileHandle
staticstdin:FileHandle
staticstdout:FileHandle
Static methods
staticclose(?file:FileHandle):Void
Function to close regular files.
staticflush():Void
Saves any written data to file.
staticinput(file:FileHandle):Void
staticinput(file:String):Void
When called with a file name, it opens the named file (in text mode), and sets its handle as the default input file. When called with a file handle, it simply sets this file handle as the default input file. When called without parameters, it returns the current default input file.
In case of errors this function raises the error, instead of returning an error code.
staticlines(?file:String):NativeIterator<String>
Opens the given file name in read mode and returns an iterator function that, each time it is called, returns a new line from the file.
staticopen(filename:String, ?mode:String):FileHandle
This function opens a file, in the mode specified in the string mode. It returns a new file handle, or, in case of errors, null
plus an error message.
The mode string can be any of the following:
-
"r"
: read mode (the default) -
"w"
: write mode -
"a"
: append mode -
"r+"
: update mode, all previous data is preserved -
"w+"
: update mode, all previous data is erased -
"a+"
: append update mode, previous data is preserved, writing is only allowed at the end of file
The mode string can also have a b
at the end, which is needed in some systems to open the file in binary mode. This string is exactly what is used in the standard C function fopen.
staticoutput(?file:String):FileHandle
staticpopen(command:String, ?mode:String):FileHandle
Starts program command
in a separated process and returns a file handle that you can use to read data from this program (if mode is "r"
, the default) or to write data to this program (if mode is "w"
).
This function is system dependent and is not available on all platforms.
staticread(?filename:String):String
staticread(?count:Int):String
statictmpfile():FileHandle
Returns a handle for a temporary file. This file is opened in update mode and it is automatically removed when the program ends.
statictype(obj:FileHandle):IoType
Checks whether obj
is a valid file handle.
staticwrite(v:Rest<String>):Void
Writes the value of each of its arguments to the file. The arguments must be strings or numbers. To write other values, use Lua.tostring
or NativeStringTools.format
before write.
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/lua/Io.html