love.filesystem.isFile and isDirectory behave consistently between PhysFS 2.0 and 2.1/3.0 (see issue #641).

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-08-06 00:53:49 -03:00
parent 9b6aa777ad
commit 7566db14f2
2 changed files with 11 additions and 3 deletions
+10 -2
View File
@@ -586,7 +586,7 @@ bool Filesystem::isDirectory(const char *dir) const
else else
return false; return false;
#else #else
return PHYSFS_isDirectory(dir) != 0; return PHYSFS_isDirectory(dir) != 0 && !isSymlink(dir);
#endif #endif
} }
@@ -595,7 +595,15 @@ bool Filesystem::isFile(const char *file) const
if (!PHYSFS_isInit()) if (!PHYSFS_isInit())
return false; return false;
return PHYSFS_exists(file) && !isDirectory(file); #ifdef LOVE_USE_PHYSFS_2_1
PHYSFS_Stat stat = {};
if (PHYSFS_stat(file, &stat))
return stat.filetype == PHYSFS_FILETYPE_REGULAR;
else
return false;
#else
return PHYSFS_exists(file) && !isDirectory(file) && !isSymlink(file);
#endif
} }
bool Filesystem::isSymlink(const char *filename) const bool Filesystem::isSymlink(const char *filename) const
+1 -1
View File
@@ -83,7 +83,7 @@ int w_newImageData(lua_State *L)
t->release(); t->release();
return 1; return 1;
} }
else if (filesystem::luax_cangetfiledata(L, 1) || luax_istype(L, 1, Data::type)) // Case 2: File(Data). else if (filesystem::luax_cangetdata(L, 1)) // Case 2: File(Data).
{ {
Data *data = love::filesystem::luax_getdata(L, 1); Data *data = love::filesystem::luax_getdata(L, 1);