diff options
| author | Reuben Thomas <rrt@sc3d.org> | 2011-06-09 14:57:27 +0100 |
|---|---|---|
| committer | Reuben Thomas <rrt@sc3d.org> | 2011-06-09 19:53:41 +0100 |
| commit | f42e7e354335caf5935d60bb8a4884abf205e20e (patch) | |
| tree | 7673c4e06eebc8442617104bfa5164770968c944 /src | |
| parent | d61eb8078dc150c4f2968c01d63d690f84a0b5b8 (diff) | |
| download | luafilesystem-f42e7e354335caf5935d60bb8a4884abf205e20e.tar.gz luafilesystem-f42e7e354335caf5935d60bb8a4884abf205e20e.tar.bz2 luafilesystem-f42e7e354335caf5935d60bb8a4884abf205e20e.zip | |
Simplify dir_iter_factory slightly.
Diffstat (limited to 'src')
| -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 | } |
