Don't use deprecated isFile in love.joystick.loadGamepadMappings (fixes #1391)

This commit is contained in:
Bart van Strien
2018-04-04 17:49:51 +02:00
parent 93372b87a8
commit 571503c02e
2 changed files with 9 additions and 9 deletions
+8 -8
View File
@@ -21,6 +21,7 @@
#include "wrap_JoystickModule.h"
#include "wrap_Joystick.h"
#include "filesystem/Filesystem.h"
#include "filesystem/wrap_Filesystem.h"
#include "sdl/JoystickModule.h"
@@ -116,15 +117,15 @@ int w_setGamepadMapping(lua_State *L)
int w_loadGamepadMappings(lua_State *L)
{
bool isfile = true;
std::string mappings;
bool isfile = false;
std::string mappings = luax_checkstring(L, 1);
if (lua_isstring(L, 1))
auto fs = Module::getInstance<love::filesystem::Filesystem>(Module::M_FILESYSTEM);
if (fs)
{
lua_pushvalue(L, 1);
luax_convobj(L, -1, "filesystem", "isFile");
isfile = luax_toboolean(L, -1);
lua_pop(L, 1);
love::filesystem::Filesystem::Info info = {};
bool exists = fs->getInfo(mappings.c_str(), info);
isfile = exists && info.type == love::filesystem::Filesystem::FILETYPE_FILE;
}
if (isfile)
@@ -132,7 +133,6 @@ int w_loadGamepadMappings(lua_State *L)
love::filesystem::FileData *fd = love::filesystem::luax_getfiledata(L, 1);
mappings = std::string((const char *) fd->getData(), fd->getSize());
fd->release();
}
else
mappings = luax_checkstring(L, 1);