From f42e7e354335caf5935d60bb8a4884abf205e20e Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 9 Jun 2011 14:57:27 +0100 Subject: Simplify dir_iter_factory slightly. --- src/lfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lfs.c b/src/lfs.c index e78aae6..ac3e712 100644 --- a/src/lfs.c +++ b/src/lfs.c @@ -465,21 +465,19 @@ static int dir_iter_factory (lua_State *L) { dir_data *d; lua_pushcfunction (L, dir_iter); d = (dir_data *) lua_newuserdata (L, sizeof(dir_data)); + luaL_getmetatable (L, DIR_METATABLE); + lua_setmetatable (L, -2); d->closed = 0; #ifdef _WIN32 d->hFile = 0L; - luaL_getmetatable (L, DIR_METATABLE); - lua_setmetatable (L, -2); if (strlen(path) > MAX_PATH-2) luaL_error (L, "path too long: %s", path); else sprintf (d->pattern, "%s/*", path); #else - luaL_getmetatable (L, DIR_METATABLE); - lua_setmetatable (L, -2); d->dir = opendir (path); if (d->dir == NULL) - luaL_error (L, "cannot open %s: %s", path, strerror (errno)); + luaL_error (L, "cannot open %s: %s", path, strerror (errno)); #endif return 2; } -- cgit v1.2.3-55-g6feb