From c863b666cc853099a4ac8637b2d391b6ac03ff2c Mon Sep 17 00:00:00 2001 From: tux <77389867@qq.com> Date: Fri, 16 Sep 2016 19:08:38 +0800 Subject: [PATCH] add pattern for lfs.dir on WIN32 --- src/lfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lfs.c b/src/lfs.c index 8154a46..5e24af6 100644 --- a/src/lfs.c +++ b/src/lfs.c @@ -545,6 +545,9 @@ static int dir_close (lua_State *L) { */ static int dir_iter_factory (lua_State *L) { const char *path = luaL_checkstring (L, 1); +#ifdef _WIN32 + const char *pattern = luaL_optstring(L, 2, "*"); +#endif dir_data *d; lua_pushcfunction (L, dir_iter); d = (dir_data *) lua_newuserdata (L, sizeof(dir_data)); @@ -556,7 +559,7 @@ static int dir_iter_factory (lua_State *L) { if (strlen(path) > MAX_PATH-2) luaL_error (L, "path too long: %s", path); else - sprintf (d->pattern, "%s/*", path); + sprintf (d->pattern, "%s/%s", path, pattern); #else d->dir = opendir (path); if (d->dir == NULL)