Merge pull request #421 from Blizzard/os_isfile-fix
Fix do_isfile to support symbolic links on Windows.
This commit is contained in:
commit
d0a34c16a9
@ -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
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user