mirror of https://github.com/axmolengine/axmol.git
avoid reopen file
This commit is contained in:
parent
0c07b05e1d
commit
2c6f7b63d1
|
@ -109,17 +109,22 @@ void Bundle3D::purgeBundle3D()
|
|||
bool Bundle3D::load(const std::string& path)
|
||||
{
|
||||
std::string strFileString = FileUtils::getInstance()->getStringFromFile(path);
|
||||
ssize_t size = strFileString.length();
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(_documentBuffer);
|
||||
_documentBuffer = new char[size + 1];
|
||||
memcpy(_documentBuffer, strFileString.c_str(), size);
|
||||
_documentBuffer[size] = '\0';
|
||||
if (document.ParseInsitu<0>(_documentBuffer).HasParseError())
|
||||
if (strFileString != _fullPath)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
ssize_t size = strFileString.length();
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(_documentBuffer);
|
||||
_documentBuffer = new char[size + 1];
|
||||
memcpy(_documentBuffer, strFileString.c_str(), size);
|
||||
_documentBuffer[size] = '\0';
|
||||
if (document.ParseInsitu<0>(_documentBuffer).HasParseError())
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
_fullPath = strFileString;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ protected:
|
|||
|
||||
char* _documentBuffer;
|
||||
rapidjson::Document document;
|
||||
std::string _fullPath;
|
||||
|
||||
bool _isBinary;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue