How to create a directory in Lua?

后端 未结 4 1119
南旧
南旧 2021-02-19 20:46

Is it possible to create a directory in lua ? If so, how ?

4条回答
  •  遇见更好的自我
    2021-02-19 21:12

    There's a "system" call (or something like that, this is from memory) which you should be able to use to run an arbitrary program, which could include the mkdir command.

    EDIT: I found my Programming in Lua book. On page 203, it mentions how you could use an

    os.execute("mkdir " .. dirname)
    

    to "fake" a directory creation command.

    EDIT 2: Take note of Jonas Thiem's warning that this command can be abused if the directory name comes from an untrusted source!

提交回复
热议问题