Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorOliver Schneider <oliver@assarbad.net>2014-02-04 05:58:43 +0400
committerOliver Schneider <oliver@assarbad.net>2014-02-04 05:58:43 +0400
commitf3a8d6f76d85612afea0ea5bdb6e3a1b3c636dc2 (patch)
tree2be103dc2dd3d50314a4f54071a552624bf86814 /src/host
parent1f3156c7d58990744a490b8ee2c729cc8784c4cd (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.c18
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;