Merge pull request #421 from Blizzard/os_isfile-fix

Fix do_isfile to support symbolic links on Windows.
This commit is contained in:
Tom van Dijck 2016-02-05 09:46:56 -08:00
commit d0a34c16a9

View File

@ -19,12 +19,18 @@ int os_isfile(lua_State* L)
int do_isfile(const char* filename)
{
struct stat buf;
#if PLATFORM_WINDOWS
DWORD attrib = GetFileAttributesA(filename);
if (attrib != INVALID_FILE_ATTRIBUTES)
{
return (attrib & FILE_ATTRIBUTE_DIRECTORY) == 0;
}
#else
if (stat(filename, &buf) == 0)
{
return ((buf.st_mode & S_IFDIR) == 0);
}
else
{
#endif
return 0;
}
}