这个是AssetsManagerEx的问题,在解压文件的时候没有创建目录,导致创建不了文件进行写入
AssetsManagerEx.cpp 337行
// Check if this entry is a directory or a file.
const size_t filenameLength = strlen(fileName);
if (fileName[filenameLength-1] == '/')
{
//There are not directory entry in some case.
//So we need to create directory when decompressing file entry
if ( !_fileUtils->createDirectory(basename(fullPath)) )
{
// Failed to create directory
CCLOG("AssetsManagerEx : can not create directory %s\n", fullPath.c_str());
unzClose(zipfile);
return false;
}
}
else
{
//////新加的代码
std::string dir = basename(fullPath);
if(!_fileUtils->isDirectoryExist(dir)) {
if(!_fileUtils->createDirectory(dir)) {
// Failed to create directory
CCLOG("AssetsManagerEx : can not create directory %s\n", fullPath.c_str());
unzClose(zipfile);
return false;
}
}

本文解决AssetsManagerEx在解压文件时未创建相应目录的问题,通过在解压前检查并创建缺失的目录,确保文件能正确写入。

1万+

被折叠的 条评论
为什么被折叠?



