How can I create tmp folder in lua?

279 Views Asked by At

How can I create temporary folder in lua?
I mean, like that i can create tmp file with os.tmpname , I looking for a way to create temporary directory.

1

There are 1 best solutions below

1
Luatic On

This is not possible using just the standard library: Lua's standard library is very limited because it is based only on C's standard library for maximum portability. There is os.tmpname or io.tmpfile but neither can be used for creating a temporary directory. For creating a temporary directory, you need more powerful libraries such as LuaPosix which provides posix.stdlib.mkdtemp(templ).

Alternatively, you could try invoking commands to create a temporary directory using os.execute or io.popen, but this would be even less portable and presumably also less efficient.