cocos2dx的android版FileUtils的坑

黄沙百战穿金甲,不破楼兰终不还。这篇文章主要讲述cocos2dx的android版FileUtils的坑相关的知识,希望能为你提供帮助。
cocos2dx3.13,FileUtils-android.cpp中可以看到:

FileUtils::Status FileUtilsAndroid::getContents(const std::string& filename, ResizableBuffer* buffer) { static const std::string apkprefix("assets/"); if (filename.empty()) return FileUtils::Status::NotExists; string fullPath = fullPathForFilename(filename); if (fullPath[0] == ‘/‘) return FileUtils::getContents(fullPath, buffer); string relativePath = string(); size_t position = fullPath.find(apkprefix); if (0 == position) { // "assets/" is at the beginning of the path and we don‘t want it relativePath += fullPath.substr(apkprefix.size()); } else { relativePath = fullPath; } ... }

  如果路径以assets/开头,则assets会被去掉。这就意味着你的Resources下不能有assets文件夹,否则下面所有的文件都会由于这个规则而无法取到。
【cocos2dx的android版FileUtils的坑】记录一下

    推荐阅读