AssetsManagerEx 解壓包含文件夾的文件時報can not create decompress destination file 錯誤的問題

這個是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;
                }

            }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章