Basic cross platform module for lua ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Basic cross platform module for lua ?

Mildred Ki'Lya
Hi,

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 ?

Something that would implement
- all filesystem functions (like file_exists, is_dir, is_file,
file_type, mkdir_recursive, mdir_recursive, unlink, rmdir and some
others)
- some way to communicate between programms (I know there are
fifos on unix but what about Windows ?) and to fork even on Windows
- all input/output functions, bufferized or not.
- an exception system for lua (I already have my module for that :)

Something I don't understand is for example why there is os.remove
and os.rename functions but not mkdir, rmdir (which are in
luafilesystem) and copy (can't find this one). Why do I need 3 modules
to handle filesystem (the standard os, luafilesystem and a home made
to have is_file, file_exists, copy, ...) ?

I think actually it's easy to write cross platform in python (for
example) since there are the cross platform batteries included. But in
lua, because I have to create them myself, and because I only have
linux, my programms can't be that easily ported to others platforms.
I'm searching for those batteries for Lua.

--
Mildred       <xmpp:[hidden email]> <http://mildred632.free.fr/>
Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]
Reply | Threaded
Open this post in threaded view
|

Re: Basic cross platform module for lua ?

David Burgess
Hi Mildred,
I am intermittently working on the same issue.
I posted some of my views on this in recent threads.

The issues I have are :
1) ansi io functions that are not in liolib.c
2) loslib.c and liolib.c

The os. functions that exist are the ANSI C defined
functions, not ANSI and Lua does not implement it.

Lua needs a set of standardized set of OS functions for
cross platform filesystem operations etc. Issue 1.

Issue 2 is the IO library, for which life gets a bit more
complex. However, I am not too far from a solution and
I will post when completed.

DB

On 4/30/06, Mildred <[hidden email]> wrote:

> Hi,
>
> 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 ?
>
> Something that would implement
> - all filesystem functions (like file_exists, is_dir, is_file,
> file_type, mkdir_recursive, mdir_recursive, unlink, rmdir and some
> others)
> - some way to communicate between programms (I know there are
> fifos on unix but what about Windows ?) and to fork even on Windows
> - all input/output functions, bufferized or not.
> - an exception system for lua (I already have my module for that :)
>
> Something I don't understand is for example why there is os.remove
> and os.rename functions but not mkdir, rmdir (which are in
> luafilesystem) and copy (can't find this one). Why do I need 3 modules
> to handle filesystem (the standard os, luafilesystem and a home made
> to have is_file, file_exists, copy, ...) ?
>
> I think actually it's easy to write cross platform in python (for
> example) since there are the cross platform batteries included. But in
> lua, because I have to create them myself, and because I only have
> linux, my programms can't be that easily ported to others platforms.
> I'm searching for those batteries for Lua.
>
> --
> Mildred       <xmpp:[hidden email]> <http://mildred632.free.fr/>
> Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
> Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]
>
Reply | Threaded
Open this post in threaded view
|

Re: Basic cross platform module for lua ?

Tomas-14
In reply to this post by Mildred Ki'Lya
  Hi Mildred

> Something I don't understand is for example why there is os.remove
> and os.rename functions but not mkdir, rmdir (which are in
> luafilesystem) and copy (can't find this one). Why do I need 3 modules
> to handle filesystem (the standard os, luafilesystem and a home made
> to have is_file, file_exists, copy, ...) ?
  Lua have only what is ANSI C.  mkdir and rmdir, for instance,
are not ANSI C.

> I think actually it's easy to write cross platform in python (for
> example) since there are the cross platform batteries included. But in
> lua, because I have to create them myself, and because I only have
> linux, my programms can't be that easily ported to others platforms.
> I'm searching for those batteries for Lua.
  You could make another library to encapsulate all of
these function if you prefer.  Some of them could be implemented above
Lua io or os libraries, some could be implemented above LFS.  I don't
know exactly what do you mean with unlink?  You should check Posix
library and if the functions you need compile on Windows.  LFS was made
to achieve that portability for the Kepler Project, but we implemented
only what we needed.
  I think you'll have some work putting all together in a
unique library but not too much :-)

  Tomas
Reply | Threaded
Open this post in threaded view
|

Re: Basic cross platform module for lua ?

Asko Kauppi
In reply to this post by Mildred Ki'Lya

The LuaX mail I wrote last night tells that those modules, including  
'lib.sys' which has pretty much what you are after (don't forget ms  
level timings ;) will eventually come out as Lua native compilable  
thingies.

If you want, we can already start working on that (hmm.. will late  
this week do?)  That would definately be better than starting from  
scratch, at least.

Also, LuaCheia had its own system module, developed about at the same  
time as LuaX 'sys' (looong ago!)

-asko


Mildred kirjoitti 30.4.2006 kello 6.40:

> Hi,
>
> 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 ?
>
> Something that would implement
> - all filesystem functions (like file_exists, is_dir, is_file,
> file_type, mkdir_recursive, mdir_recursive, unlink, rmdir and some
> others)
> - some way to communicate between programms (I know there are
> fifos on unix but what about Windows ?) and to fork even on Windows
> - all input/output functions, bufferized or not.
> - an exception system for lua (I already have my module for that :)
>
> Something I don't understand is for example why there is os.remove
> and os.rename functions but not mkdir, rmdir (which are in
> luafilesystem) and copy (can't find this one). Why do I need 3 modules
> to handle filesystem (the standard os, luafilesystem and a home made
> to have is_file, file_exists, copy, ...) ?
>
> I think actually it's easy to write cross platform in python (for
> example) since there are the cross platform batteries included. But in
> lua, because I have to create them myself, and because I only have
> linux, my programms can't be that easily ported to others platforms.
> I'm searching for those batteries for Lua.
>
> --
> Mildred       <xmpp:[hidden email]> <http://mildred632.free.fr/>
> Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/ 
> gpg_key>
> Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]

Reply | Threaded
Open this post in threaded view
|

Re: Basic cross platform module for lua ?

Alex Queiroz
Hallo,

On 4/30/06, Asko Kauppi <[hidden email]> wrote:
>
> If you want, we can already start working on that (hmm.. will late
> this week do?)  That would definately be better than starting from
> scratch, at least.
>

     As I am now writing a web app in Lua, I am another one who misses
general purpose Lua libraries, something like boost for Lua.

--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|

Re: Basic cross platform module for lua ?

Petite Abeille
In reply to this post by Mildred Ki'Lya

On Apr 30, 2006, at 05:40, Mildred wrote:

> I think actually it's easy to write cross platform in python (for
> example) since there are the cross platform batteries included. But in
> lua, because I have to create them myself, and because I only have
> linux, my programms can't be that easily ported to others platforms.
> I'm searching for those batteries for Lua.

Hmmm... once you internalize the fact that Lua is the quintessential
BYO [1] environment, life gets much smoother 8^)

For what it's worth, here is what I use for my own Lua web application
server:

The Basics

Kepler's LuaFileSystem
http://www.keplerproject.org/luafilesystem/

Diego Nehab's LuaSocket
http://www.cs.princeton.edu/~diego/professional/luasocket/

One you have file and network access, the rest is gravy, but still:

Klaus Ripke's slncrypto (sha1, blowfish)
http://luaforge.net/projects/sln/

Luiz Henrique de Figueiredo's lgdbm, lmd5, lrandom, luuid
http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/

Tiago Dionizio's lgzip
http://mega.ist.utl.pt/~tngd/lua/

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/


[1] http://en.wikipedia.org/wiki/BYO

Reply | Threaded
Open this post in threaded view
|

Re: Basic cross platform module for lua ?

Mark Edgar
In reply to this post by Mildred Ki'Lya
Mildred wrote:
 > Hi,
 >
 > 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
 > others)

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()
primitives.

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
process spawning.

 > - 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.

                                        -Mark