diff options
-rw-r--r-- | src/lfs.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -465,21 +465,19 @@ static int dir_iter_factory (lua_State *L) { | |||
465 | dir_data *d; | 465 | dir_data *d; |
466 | lua_pushcfunction (L, dir_iter); | 466 | lua_pushcfunction (L, dir_iter); |
467 | d = (dir_data *) lua_newuserdata (L, sizeof(dir_data)); | 467 | d = (dir_data *) lua_newuserdata (L, sizeof(dir_data)); |
468 | luaL_getmetatable (L, DIR_METATABLE); | ||
469 | lua_setmetatable (L, -2); | ||
468 | d->closed = 0; | 470 | d->closed = 0; |
469 | #ifdef _WIN32 | 471 | #ifdef _WIN32 |
470 | d->hFile = 0L; | 472 | d->hFile = 0L; |
471 | luaL_getmetatable (L, DIR_METATABLE); | ||
472 | lua_setmetatable (L, -2); | ||
473 | if (strlen(path) > MAX_PATH-2) | 473 | if (strlen(path) > MAX_PATH-2) |
474 | luaL_error (L, "path too long: %s", path); | 474 | luaL_error (L, "path too long: %s", path); |
475 | else | 475 | else |
476 | sprintf (d->pattern, "%s/*", path); | 476 | sprintf (d->pattern, "%s/*", path); |
477 | #else | 477 | #else |
478 | luaL_getmetatable (L, DIR_METATABLE); | ||
479 | lua_setmetatable (L, -2); | ||
480 | d->dir = opendir (path); | 478 | d->dir = opendir (path); |
481 | if (d->dir == NULL) | 479 | if (d->dir == NULL) |
482 | luaL_error (L, "cannot open %s: %s", path, strerror (errno)); | 480 | luaL_error (L, "cannot open %s: %s", path, strerror (errno)); |
483 | #endif | 481 | #endif |
484 | return 2; | 482 | return 2; |
485 | } | 483 | } |