There are two solutions in standard Lua:
io.tmpfile
, which returns a handle for a temporary file. This file is opened in update mode and it is automatically removed when the program ends.os.tmpname
, which returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed.