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.
Asked
Active
Viewed 132 times
3

user123454321
- 132
- 6
1 Answers
2
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.

Luatic
- 8,513
- 2
- 13
- 34
-
can please help with this question https://stackoverflow.com/questions/74943547/should-i-check-the-returned-value-in-this-case ? – user123454321 Dec 28 '22 at 18:25