Merge pull request #1484 from LORgames/ssurtees/symlink

Fixed issue with os.matchfiles and symlinks
This commit is contained in:
starkos 2020-07-10 14:56:25 -04:00 committed by GitHub
commit 08a19770f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -161,9 +161,10 @@ int os_matchisfile(lua_State* L)
{
MatchInfo* m = (MatchInfo*)lua_touserdata(L, 1);
#if defined(_DIRENT_HAVE_D_TYPE)
if (m->entry->d_type != DT_UNKNOWN)
// Dirent marks symlinks as DT_LNK, not (DT_LNK|DT_DIR). The fallback handles symlinks using stat.
if (m->entry->d_type == DT_DIR)
{
lua_pushboolean(L, (m->entry->d_type == DT_DIR) == 0);
lua_pushboolean(L, 0);
}
else
#endif

View File

@ -124,6 +124,20 @@
test.istrue(table.contains(result, "folder/subfolder/hello.txt"))
end
function suite.matchfiles_onSymbolicLink()
if os.istarget("macosx")
or os.istarget("linux")
or os.istarget("solaris")
or os.istarget("bsd")
then
os.execute("cd folder && ln -s subfolder symlinkfolder && cd ..")
local result = os.matchfiles("folder/**/*.txt")
os.execute("rm folder/symlinkfolder")
premake.modules.self_test.print(table.tostring(result))
test.istrue(table.contains(result, "folder/symlinkfolder/hello.txt"))
end
end
--
-- os.pathsearch() tests