#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
auto xx_imgs = FileUtils::getInstance()->fullPathForFilename(filename);
return xx_imgs;
#else
// 资源路径
std::string sourcePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(filename);
// 可写路径
std::string destPath = cocos2d::FileUtils::getInstance()->getWritablePath() + filename;
if (cocos2d::FileUtils::getInstance()->isFileExist(destPath)) {
return destPath;
}
if (cocos2d::FileUtils::getInstance()->isFileExist(destPath + ".tmp")) {
cocos2d::FileUtils::getInstance()->removeFile(destPath + ".tmp");
}
// write
cocos2d::Data data = cocos2d::FileUtils::getInstance()->getDataFromFile(sourcePath);
FILE *fp = fopen(destPath.c_str(), "w+");
if (fp)
{
size_t size = fwrite(data.getBytes(), sizeof(unsigned char), data.getSize(), fp);
fclose(fp);
if (size > 0)
{
return destPath;
}
}
CCLOG("copy file %s failed.", filename.c_str());
return "";
#endif