Io
Supported platforms:
Available since: Gideros 2011.6
Description
Manages main input/output operations.
Examples
Create a file with default values
local hex1
local hex2
local hex3
local file = io.open("|D|theme.txt", "r")
if not file then
hex1 = 0x280d1d
hex2 = 0x581422
hex3 = 0x622334
file = io.open("|D|theme.txt", "w+")
file:write(hex1.."\n")
file:write(hex2.."\n")
file:write(hex3.."\n")
file:close()
else
hex1 = file:read("*line")
hex2 = file:read("*line")
hex3 = file:read("*line")
file:close()
end
print(hex1, hex2, hex3)
To copy a file
local function copy(src, dst)
local srcf = io.open(src, "rb")
local dstf = io.open(dst, "wb")
local size = 2^13 -- good buffer size (8K)
while true do
local block = srcf:read(size)
if not block then break end
dstf:write(block)
end
srcf:close()
dstf:close()
end
Methodsio.close closes file, or the default output file |
EventsConstants |