mirror of
https://github.com/lunarmodules/luafilesystem.git
synced 2026-07-25 05:03:07 +00:00
Full Lua 5.2 compatibility and adherance to modules-create-no-globals
This commit is contained in:
@@ -65,7 +65,7 @@
|
|||||||
attributes for each file inside it.</p>
|
attributes for each file inside it.</p>
|
||||||
|
|
||||||
<pre class="example">
|
<pre class="example">
|
||||||
require"lfs"
|
local lfs = require"lfs"
|
||||||
|
|
||||||
function attrdir (path)
|
function attrdir (path)
|
||||||
for file in lfs.dir(path) do
|
for file in lfs.dir(path) do
|
||||||
|
|||||||
20
src/lfs.c
20
src/lfs.c
@@ -56,20 +56,14 @@
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LUA_COMPAT_ALL
|
#include <lua.h>
|
||||||
#include "lua.h"
|
#include <lauxlib.h>
|
||||||
#include "lauxlib.h"
|
#include <lualib.h>
|
||||||
#include "lualib.h"
|
|
||||||
#include "lfs.h"
|
#include "lfs.h"
|
||||||
|
|
||||||
/*
|
#if LUA_VERSION_NUM < 502
|
||||||
* ** compatibility with Lua 5.2
|
# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
|
||||||
* */
|
|
||||||
#if (LUA_VERSION_NUM == 502)
|
|
||||||
#undef luaL_register
|
|
||||||
#define luaL_register(L,n,f) \
|
|
||||||
{ if ((n) == NULL) luaL_setfuncs(L,f,0); else luaL_newlib(L,f); }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define 'strerror' for systems that do not implement it */
|
/* Define 'strerror' for systems that do not implement it */
|
||||||
@@ -881,7 +875,7 @@ static const struct luaL_Reg fslib[] = {
|
|||||||
int luaopen_lfs (lua_State *L) {
|
int luaopen_lfs (lua_State *L) {
|
||||||
dir_create_meta (L);
|
dir_create_meta (L);
|
||||||
lock_create_meta (L);
|
lock_create_meta (L);
|
||||||
luaL_register (L, "lfs", fslib);
|
luaL_newlib (L, fslib);
|
||||||
set_info (L);
|
set_info (L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user