diff options
author | Oliver Schneider <oliver@assarbad.net> | 2014-02-04 05:58:43 +0400 |
---|---|---|
committer | Oliver Schneider <oliver@assarbad.net> | 2014-02-04 05:58:43 +0400 |
commit | f3a8d6f76d85612afea0ea5bdb6e3a1b3c636dc2 (patch) | |
tree | 2be103dc2dd3d50314a4f54071a552624bf86814 /src/host | |
parent | 1f3156c7d58990744a490b8ee2c729cc8784c4cd (diff) |
Fixing issue #20: os.matchfiles misses matching files
--HG--
branch : WDS-build
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/os_match.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/host/os_match.c b/src/host/os_match.c index a267381..cd4f492 100644 --- a/src/host/os_match.c +++ b/src/host/os_match.c @@ -25,7 +25,7 @@ int os_matchstart(lua_State* L) { const char* mask = luaL_checkstring(L, 1); MatchInfo* m = (MatchInfo*)malloc(sizeof(MatchInfo)); - m->handle = FindFirstFile(mask, &m->entry); + m->handle = FindFirstFile(mask, &m->entry); /* error handling happens in os_matchnext() below */ m->is_first = 1; lua_pushlightuserdata(L, m); return 1; @@ -69,11 +69,17 @@ int os_matchnext(lua_State* L) } m->is_first = 0; - if (m->entry.cFileName[0] != '.') - { - lua_pushboolean(L, 1); - return 1; - } + /* Ignore the directory entries for . and .. only */ + if (m->entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + if (m->entry.cFileName[0] == '.') + { + if (m->entry.cFileName[1] == '\0') + continue; + if (m->entry.cFileName[1] == '.' && m->entry.cFileName[2] == '\0') + continue; + } + lua_pushboolean(L, 1); + return 1; } return 0; |