diff options
author | Oliver Schneider <oliver@assarbad.net> | 2014-02-05 05:12:12 +0400 |
---|---|---|
committer | Oliver Schneider <oliver@assarbad.net> | 2014-02-05 05:12:12 +0400 |
commit | a1be5c376466b1e028eec2738904228b989fc9ac (patch) | |
tree | f5f31e5c9d2d83f8f3e6311ca851a3ae07293704 /src/host | |
parent | 6fe3ee648cf35dacc16eecb43b6b3407bd6fd3fe (diff) |
Addressing issue #20 for the unixoid systems
--HG--
branch : WDS-build
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/os_match.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/host/os_match.c b/src/host/os_match.c index cd4f492..460bf5f 100644 --- a/src/host/os_match.c +++ b/src/host/os_match.c @@ -8,6 +8,17 @@ #include <string.h> #include "premake.h" +static int skip_dot_entries(const char* name) +{ + if (name[0] == '.') + { + if (name[1] == '\0') + return 1; + if (name[1] == '.' && name[2] == '\0') + return 1; + } + return 0; +} #if PLATFORM_WINDOWS @@ -71,13 +82,8 @@ int os_matchnext(lua_State* L) m->is_first = 0; /* 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; - } + if (skip_dot_entries(m->entry.cFileName)) + continue; lua_pushboolean(L, 1); return 1; } @@ -175,11 +181,13 @@ int os_matchnext(lua_State* L) while (m->entry != NULL) { const char* name = m->entry->d_name; - if (name[0] != '.' && fnmatch(m->mask, name, 0) == 0) - { - lua_pushboolean(L, 1); - return 1; - } + /* Ignore the directory entries for . and .. only */ + if (!skip_dot_entries(name)) + if (fnmatch(m->mask, name, 0) == 0) + { + lua_pushboolean(L, 1); + return 1; + } m->entry = readdir(m->handle); } |