MCPcopy Create free account
hub / github.com/9miao/CrossApp / getFileData

Method getFileData

CrossApp/platform/CCFileUtils.cpp:47–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
48{
49 unsigned char * pBuffer = NULL;
50 CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters.");
51 *pSize = 0;
52 do
53 {
54 // read the file from hardware
55 std::string fullPath = fullPathForFilename(pszFileName);
56 FILE *fp = fopen(fullPath.c_str(), pszMode);
57 CC_BREAK_IF(!fp);
58
59 fseek(fp,0,SEEK_END);
60 *pSize = ftell(fp);
61 fseek(fp,0,SEEK_SET);
62 pBuffer = new unsigned char[*pSize];
63 *pSize = fread(pBuffer,sizeof(unsigned char), *pSize,fp);
64 fclose(fp);
65 } while (0);
66
67 if (! pBuffer)
68 {
69 std::string msg = "Get data from file(";
70 msg.append(pszFileName).append(") failed!");
71
72 CCLOG("%s", msg.c_str());
73 }
74 return pBuffer;
75}
76
77unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize)
78{

Callers 11

getFileStringMethod · 0.95
runScriptMethod · 0.45
loadEmojiFontBufferMethod · 0.45
parseMethod · 0.45
loadFontMethod · 0.45
initWithImageFileMethod · 0.45
initWithFilePathMethod · 0.45
CCGameSWF_file_openerFunction · 0.45

Calls 2

c_strMethod · 0.45
appendMethod · 0.45