[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Basic cross platform module for lua ?
- From: Mark Edgar <medgar@...>
- Date: Tue, 02 May 2006 12:26:50 -0700
> I'm searching for a lua module that would be cross platform for the
> main desktop OS that would provide all basic functions that I need
> without the the neeed to require some others modules.
> Does something like that exists or do I have to create it ?
There is a project http://lua-users.org/wiki/ExtensionProprosal which
meets some of your feature requirements:
> Something that would implement
> - all filesystem functions (like file_exists, is_dir, is_file,
> file_type, mkdir_recursive, mdir_recursive, unlink, rmdir and some
The ex.dirent() function combined with os.remove() should provide most
of the above. I would suggest that mkdir_recursive can be implemented
in pure Lua using only the ex.mkdir() primitive. rmdir_recursive can
also be implemented in pure Lua using the ex.dir() and os.remove()
You'll find that most O/S APIs do not typically provide high-level
functions such as these. An implementation of the typical command line
file copy program ('cp' or 'copy') is done not by calling a single OS
primitive, but by opening each input and output file and reading and
writing the contents. Such a file copy function can also be written in
pure Lua using io.open() and the standard file methods.
> - some way to communicate between programms (I know there are
> fifos on unix but what about Windows ?) and to fork even on Windows
You probably only need pipes, which ex.pipe() provides. And of course
the ex.spawn() function works with pipes to provide general purpose
> - all input/output functions, bufferized or not.
I'm not sure to what you are referring here. The ex API is meant to
integrate tightly into the standard io and os modules so ex.pipe()
returns valid "file" objects which have all the standard methods
provided by the io module.
The ex API doesn't currently provide for setting the buffering mode of
any file object, nor does it guarantee the flush timing of pipes.
> - an exception system for lua (I already have my module for that :)
Good because the ex API doesn't attempt to provide a solution here. :)
Try it out, and let me know if the ex API semantics provide what you need.