mirror of https://github.com/axmolengine/axmol.git
[win32] Fixes cpp-tests/FileUtilsTest crash. (#17551)
This commit is contained in:
parent
a493456770
commit
3bd09ae286
|
@ -35,7 +35,7 @@ void TestResolutionDirectories::onEnter()
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
|
||||||
sharedFileUtils->purgeCachedEntries();
|
sharedFileUtils->purgeCachedEntries();
|
||||||
_defaultSearchPathArray = sharedFileUtils->getSearchPaths();
|
_defaultSearchPathArray = sharedFileUtils->getOriginalSearchPaths();
|
||||||
std::vector<std::string> searchPaths = _defaultSearchPathArray;
|
std::vector<std::string> searchPaths = _defaultSearchPathArray;
|
||||||
searchPaths.insert(searchPaths.begin(), "Misc");
|
searchPaths.insert(searchPaths.begin(), "Misc");
|
||||||
sharedFileUtils->setSearchPaths(searchPaths);
|
sharedFileUtils->setSearchPaths(searchPaths);
|
||||||
|
@ -89,7 +89,7 @@ void TestSearchPath::onEnter()
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
|
||||||
sharedFileUtils->purgeCachedEntries();
|
sharedFileUtils->purgeCachedEntries();
|
||||||
_defaultSearchPathArray = sharedFileUtils->getSearchPaths();
|
_defaultSearchPathArray = sharedFileUtils->getOriginalSearchPaths();
|
||||||
std::vector<std::string> searchPaths = _defaultSearchPathArray;
|
std::vector<std::string> searchPaths = _defaultSearchPathArray;
|
||||||
std::string writablePath = sharedFileUtils->getWritablePath();
|
std::string writablePath = sharedFileUtils->getWritablePath();
|
||||||
std::string fileName = writablePath+"external.txt";
|
std::string fileName = writablePath+"external.txt";
|
||||||
|
@ -139,7 +139,7 @@ void TestSearchPath::onEnter()
|
||||||
|
|
||||||
// Save old resource root path
|
// Save old resource root path
|
||||||
std::string oldDefaultRootPath = sharedFileUtils->getDefaultResourceRootPath();
|
std::string oldDefaultRootPath = sharedFileUtils->getDefaultResourceRootPath();
|
||||||
sharedFileUtils->setDefaultResourceRootPath("extensions");
|
sharedFileUtils->setDefaultResourceRootPath(oldDefaultRootPath + "extensions");
|
||||||
auto sp1 = Sprite::create("orange_edit.png");
|
auto sp1 = Sprite::create("orange_edit.png");
|
||||||
sp1->setPosition(VisibleRect::center());
|
sp1->setPosition(VisibleRect::center());
|
||||||
addChild(sp1);
|
addChild(sp1);
|
||||||
|
@ -147,7 +147,7 @@ void TestSearchPath::onEnter()
|
||||||
// Recover resource root path
|
// Recover resource root path
|
||||||
sharedFileUtils->setDefaultResourceRootPath(oldDefaultRootPath);
|
sharedFileUtils->setDefaultResourceRootPath(oldDefaultRootPath);
|
||||||
|
|
||||||
auto oldSearchPaths = sharedFileUtils->getSearchPaths();
|
auto oldSearchPaths = sharedFileUtils->getOriginalSearchPaths();
|
||||||
sharedFileUtils->addSearchPath("Images");
|
sharedFileUtils->addSearchPath("Images");
|
||||||
auto sp2 = Sprite::create("btn-about-normal.png");
|
auto sp2 = Sprite::create("btn-about-normal.png");
|
||||||
sp2->setPosition(VisibleRect::center() + Vec2(0, -50));
|
sp2->setPosition(VisibleRect::center() + Vec2(0, -50));
|
||||||
|
|
|
@ -952,7 +952,7 @@ void AudioPlayFileInWritablePath::onEnter()
|
||||||
std::string musicFile = "background.mp3";
|
std::string musicFile = "background.mp3";
|
||||||
std::string saveFilePath = writablePath + "background_in_writable_dir.mp3";
|
std::string saveFilePath = writablePath + "background_in_writable_dir.mp3";
|
||||||
|
|
||||||
_oldSearchPaths = fileUtils->getSearchPaths();
|
_oldSearchPaths = fileUtils->getOriginalSearchPaths();
|
||||||
fileUtils->addSearchPath(writablePath, true);
|
fileUtils->addSearchPath(writablePath, true);
|
||||||
|
|
||||||
if (!fileUtils->isFileExist(saveFilePath))
|
if (!fileUtils->isFileExist(saveFilePath))
|
||||||
|
|
|
@ -113,18 +113,7 @@ static int lua_cocos2dx_addSearchPath(lua_State* L)
|
||||||
#endif
|
#endif
|
||||||
std::string pathToSave = tolua_tostring(L, 1, "");
|
std::string pathToSave = tolua_tostring(L, 1, "");
|
||||||
bool before = tolua_toboolean(L, 2, 0);
|
bool before = tolua_toboolean(L, 2, 0);
|
||||||
std::vector<std::string> searchPaths = FileUtils::getInstance()->getSearchPaths();
|
FileUtils::getInstance()->addSearchPath(pathToSave, before);
|
||||||
if (before)
|
|
||||||
{
|
|
||||||
searchPaths.insert(searchPaths.begin(), pathToSave);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
searchPaths.push_back(pathToSave);
|
|
||||||
}
|
|
||||||
|
|
||||||
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
CCLOG("'addSearchPath' function wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
CCLOG("'addSearchPath' function wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
||||||
|
|
Loading…
Reference in New Issue