| 75 | } |
| 76 | |
| 77 | unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize) |
| 78 | { |
| 79 | unsigned char * pBuffer = NULL; |
| 80 | unzFile pFile = NULL; |
| 81 | *pSize = 0; |
| 82 | |
| 83 | do |
| 84 | { |
| 85 | CC_BREAK_IF(!pszZipFilePath || !pszFileName); |
| 86 | CC_BREAK_IF(strlen(pszZipFilePath) == 0); |
| 87 | |
| 88 | pFile = unzOpen(pszZipFilePath); |
| 89 | CC_BREAK_IF(!pFile); |
| 90 | |
| 91 | int nRet = unzLocateFile(pFile, pszFileName, 1); |
| 92 | CC_BREAK_IF(UNZ_OK != nRet); |
| 93 | |
| 94 | char szFilePathA[260]; |
| 95 | unz_file_info FileInfo; |
| 96 | nRet = unzGetCurrentFileInfo(pFile, &FileInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0); |
| 97 | CC_BREAK_IF(UNZ_OK != nRet); |
| 98 | |
| 99 | nRet = unzOpenCurrentFile(pFile); |
| 100 | CC_BREAK_IF(UNZ_OK != nRet); |
| 101 | |
| 102 | pBuffer = new unsigned char[FileInfo.uncompressed_size]; |
| 103 | int CC_UNUSED nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size); |
| 104 | CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong"); |
| 105 | |
| 106 | *pSize = FileInfo.uncompressed_size; |
| 107 | unzCloseCurrentFile(pFile); |
| 108 | } while (0); |
| 109 | |
| 110 | if (pFile) |
| 111 | { |
| 112 | unzClose(pFile); |
| 113 | } |
| 114 | |
| 115 | return pBuffer; |
| 116 | } |
| 117 | |
| 118 | std::string CCFileUtils::getFileString(const char* pszFilePath) |
| 119 | { |
nothing calls this directly
no test coverage detected