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)
|
bool Bundle3D::load(const std::string& path)
|
||||||
{
|
{
|
||||||
std::string strFileString = FileUtils::getInstance()->getStringFromFile(path);
|
std::string strFileString = FileUtils::getInstance()->getStringFromFile(path);
|
||||||
ssize_t size = strFileString.length();
|
if (strFileString != _fullPath)
|
||||||
|
|
||||||
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);
|
ssize_t size = strFileString.length();
|
||||||
return false;
|
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ protected:
|
||||||
|
|
||||||
char* _documentBuffer;
|
char* _documentBuffer;
|
||||||
rapidjson::Document document;
|
rapidjson::Document document;
|
||||||
|
std::string _fullPath;
|
||||||
|
|
||||||
bool _isBinary;
|
bool _isBinary;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue