b2World* b2dJson::readFromFile(const char* filename, std::string& errorMsg)
{
if (!filename)
return NULL;
std::string path = filename;
cocos2d::CCFileUtils::sharedFileUtils()->removeSuffixFromFile(path);
filename = cocos2d::CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path.c_str());
cocos2d::CCLog(filename);
std::ifstream ifs;
ifs.open(filename, std::ios::in);
if (!ifs) {
//std::cout << "Could not open file " << filename << " for reading
";
errorMsg = string("Could not open file ) + string(filename) + string( for reading");
return NULL;
}
Json::Value worldValue;
Json::Reader reader;
if ( ! reader.parse(ifs, worldValue) )
{
//std::cout << "Failed to parse " << filename << std::endl << reader.getFormattedErrorMessages();
errorMsg = string("Failed to parse ) + string(filename) + string( : ") + reader.getFormatedErrorMessages();
ifs.close();
return NULL;
}
ifs.close();
return j2b2World(worldValue);
}
请问这里面的path有错误么 我编译到android上面 得不到传入的文件 谢谢 指导