io.tmpfile

Returns a handle to a temporary file

Prototype

f = io.tmpfile ()

Description

Returns a handle to a temporary file, opened in update mode. Automatically removed when the program ends.

f = assert (io.tmpfile ()) -- open temporary file
f:write ("some data here")  -- write to it
f:seek ("set", 0) -- back to start
s = f:read ("*a")  -- read all of it back in
print (s)  -- print out
f:close ()  -- close file

-->

some data here

If the file cannot be opened the function returns 3 things:

Lua functions

Topics