mirror of https://github.com/axmolengine/axmol.git
Compatibility code for executeScriptFile
This commit is contained in:
parent
1b96b0bef8
commit
cbf9741dfd
|
@ -276,8 +276,30 @@ int LuaStack::executeScriptFile(const char* filename)
|
||||||
{
|
{
|
||||||
CCAssert(filename, "CCLuaStack::executeScriptFile() - invalid filename");
|
CCAssert(filename, "CCLuaStack::executeScriptFile() - invalid filename");
|
||||||
|
|
||||||
|
static const std::string BYTECODE_FILE_EXT = ".luac";
|
||||||
|
static const std::string NOT_BYTECODE_FILE_EXT = ".lua";
|
||||||
|
|
||||||
FileUtils *utils = FileUtils::getInstance();
|
FileUtils *utils = FileUtils::getInstance();
|
||||||
std::string fullPath = utils->fullPathForFilename(filename);
|
//
|
||||||
|
// 1. check .lua suffix
|
||||||
|
// 2. check .luac suffix
|
||||||
|
//
|
||||||
|
std::string buf(filename);
|
||||||
|
std::string tmpfilename = buf + NOT_BYTECODE_FILE_EXT;
|
||||||
|
if (utils->isFileExist(tmpfilename))
|
||||||
|
{
|
||||||
|
buf = tmpfilename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmpfilename = buf + BYTECODE_FILE_EXT;
|
||||||
|
if (utils->isFileExist(tmpfilename))
|
||||||
|
{
|
||||||
|
buf = tmpfilename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string fullPath = utils->fullPathForFilename(buf);
|
||||||
Data data = utils->getDataFromFile(fullPath);
|
Data data = utils->getDataFromFile(fullPath);
|
||||||
int rn = 0;
|
int rn = 0;
|
||||||
if (!data.isNull())
|
if (!data.isNull())
|
||||||
|
|
Loading…
Reference in New Issue