Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create tmp folder in lua?

Tags:

lua

tmp

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.

like image 398
user123454321 Avatar asked Mar 07 '26 13:03

user123454321


1 Answers

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.

like image 146
LMD Avatar answered Mar 10 '26 15:03

LMD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!