views:

560

answers:

2

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

+4  A: 

I'm pretty sure it is; look in the "os" part of the library!

Failing that, 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.

Carl Smotricz
The Lua design philosophy is to be pure ISO C, so as to be portable to anything with a C compiler. There is no directory creation function in the C standard library. This is left up to platform-specific extensions, like mkdir(2) on POSIX systems and CreateDirectory*() on Windows.
Warren Young
Thanks ;) ! I knew I could do that kind of execute(), but I was wondering if there was a Lua alternative... I guess there isn't ;) !
Wookai
+7  A: 

You may find the LuaFileSystem library useful. It has a mkdir function.

Arthur Reutenauer
Thanks for the link ! I can't user other libraires for the moment, so I'll stick with the os.execute() version, but I'll keep LuaFileSystem in mind for next time !
Wookai