* CCFileUtils_ios dump error message to console

This commit is contained in:
YuLei Liao 2011-11-23 13:36:32 +08:00
parent b34859108e
commit 01c8f5f47e
1 changed files with 22 additions and 7 deletions

View File

@ -291,7 +291,16 @@ namespace cocos2d {
pRet->m_sString += pszFilename;
return pRet->m_sString.c_str();
}
CCDictionary<std::string, CCObject*> *CCFileUtils::dictionaryWithContentsOfFile(const char *pFileName)
{
CCDictionary<std::string, CCObject*> *ret = dictionaryWithContentsOfFileThreadSafe(pFileName);
ret->autorelease();
return ret;
}
CCDictionary<std::string, CCObject*> *CCFileUtils::dictionaryWithContentsOfFileThreadSafe(const char *pFileName)
{
NSString* pPath = [NSString stringWithUTF8String:pFileName];
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
@ -301,9 +310,10 @@ namespace cocos2d {
id value = [pDict objectForKey:key];
static_addValueToCCDict(key, value, pRet);
}
pRet->autorelease();
return pRet;
}
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{
unsigned char * pBuffer = NULL;
@ -321,14 +331,19 @@ namespace cocos2d {
*pSize = fread(pBuffer,sizeof(unsigned char), *pSize,fp);
fclose(fp);
} while (0);
if (! pBuffer && getIsPopupNotify())
if (! pBuffer)
{
std::string title = "Notification";
std::string msg = "Get data from file(";
msg.append(pszFileName).append(") failed!");
CCLOG("Get data from file(%s) failed!", pszFileName);
if (getIsPopupNotify())
{
std::string title = "Notification";
std::string msg = "Get data from file(";
msg.append(pszFileName).append(") failed!");
CCMessageBox(msg.c_str(), title.c_str());
CCMessageBox(msg.c_str(), title.c_str());
}
}
return pBuffer;
}