lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sean Conner <sean@conman.org> 于2020年1月21日周二 下午1:38写道:
>
> It was thus said that the Great Lorenzo Donati once stated:
> >
> > Sadly this won't solve the basic problem: an unified, cross-platform
> > (Windows included) set of libraries whose behavior is the same on all
> > systems (bar system-specific subsets).
> >
> > For that some kind of "mandated/blessed" API specifications would be needed.
>
>   Okay, let's see if the community can just come together to define the
> minimum viable module for directory functions.  I'm looking at three
> different modules that implement such functionality, LuaFileSystem, luaposix
> and my own org.conman.fsys module.
>
>   LuaFileSystem and luaposix are largely compatible---for instance, both
> have rmdir(), and they both return the same information:
>
>         happy path:     0
>         sad path:       nil,"error string",err_integer
>
>   This mimics the Lua file API.  I'm not happy with that, so when I wrote my
> own, I did:
>
>         happy path:     true,0
>         sad path:       false,err_integer
>
>   My thoughts for returning an error number instead of a string is that the
> number is easier for error handling and if I want to print out a string, I
> can use a wrapper for strerror() at that point.  But aside from error
> reporting, all three APIs are similar enough to get a feel for what might
> make the minimum library.  Here's what I have so far (excluding the error
> reporting):
>
I have my own module for directory functions[1], and I found that if
you want cross platform native directory operations, you can not
always get errno. Windows has its own routines and error codes for
that.

I'm planing a new module named lua-pathlib for compatible with the
Python pathlib module, it offers a OO interface for paths. I will try
to implement in my Chinese Festival holiday and release later.

[1]: https://github.com/starwing/lpath

-- 
regards,
Xavier Wang.