From b9b14571ac3e21f252b1483a101065ccea810d0b Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 7 Nov 2013 17:16:31 +0800 Subject: [PATCH] fix compiling erros on Android --- cocos/2d/CCUserDefaultAndroid.cpp | 4 +- .../platform/android/CCFileUtilsAndroid.cpp | 40 +++++++++---------- .../2d/platform/android/CCFileUtilsAndroid.h | 6 +-- cocos/gui/UILayoutDefine.h | 1 - 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/cocos/2d/CCUserDefaultAndroid.cpp b/cocos/2d/CCUserDefaultAndroid.cpp index 38c09c2a90..db18dd2951 100644 --- a/cocos/2d/CCUserDefaultAndroid.cpp +++ b/cocos/2d/CCUserDefaultAndroid.cpp @@ -74,8 +74,8 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc { tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; - unsigned long nSize; - const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize); + long size; + const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); //const char* pXmlBuffer = (const char*)data.getBuffer(); if(NULL == pXmlBuffer) { diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp index d15e4f874a..c447b5db32 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp @@ -130,21 +130,21 @@ bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) const } -unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* mode, long * size) { - return doGetFileData(filename, pszMode, pSize, false); + return doGetFileData(filename, mode, size, false); } -unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, long * pSize) { return doGetFileData(filename, pszMode, pSize, true); } -unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync) +unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* mode, long * size, bool forAsync) { - unsigned char * pData = 0; + unsigned char * data = 0; - if ((! filename) || (! pszMode) || 0 == strlen(filename)) + if ((! filename) || (! mode) || 0 == strlen(filename)) { return 0; } @@ -189,14 +189,14 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* return NULL; } - off_t size = AAsset_getLength(asset); + off_t fileSize = AAsset_getLength(asset); - pData = new unsigned char[size]; + data = new unsigned char[fileSize]; - int bytesread = AAsset_read(asset, (void*)pData, size); - if (pSize) + int bytesread = AAsset_read(asset, (void*)data, fileSize); + if (size) { - *pSize = bytesread; + *size = bytesread; } AAsset_close(asset); @@ -207,32 +207,32 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* { // read rrom other path than user set it //CCLOG("GETTING FILE ABSOLUTE DATA: %s", filename); - FILE *fp = fopen(fullPath.c_str(), pszMode); + FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); - unsigned long size; + long fileSize; fseek(fp,0,SEEK_END); - size = ftell(fp); + fileSize = ftell(fp); fseek(fp,0,SEEK_SET); - pData = new unsigned char[size]; - size = fread(pData,sizeof(unsigned char), size,fp); + data = new unsigned char[fileSize]; + fileSize = fread(data,sizeof(unsigned char), fileSize,fp); fclose(fp); - if (pSize) + if (size) { - *pSize = size; + *size = fileSize; } } while (0); } - if (! pData) + if (! data) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } - return pData; + return data; } string FileUtilsAndroid::getWritablePath() const diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.h b/cocos/2d/platform/android/CCFileUtilsAndroid.h index 87a2445f48..3bee6d2e39 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.h +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.h @@ -55,7 +55,7 @@ public: /* override funtions */ bool init(); - virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize); + virtual unsigned char* getFileData(const char* filename, const char* mode, long * size); virtual std::string getWritablePath() const; virtual bool isFileExist(const std::string& strFilePath) const; @@ -64,10 +64,10 @@ public: /** This function is android specific. It is used for TextureCache::addImageAsync(). Don't use it in your codes. */ - unsigned char* getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize); + unsigned char* getFileDataForAsync(const char* filename, const char* mode, long * size); private: - unsigned char* doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync); + unsigned char* doGetFileData(const char* filename, const char* mode, long * size, bool forAsync); static AAssetManager* assetmanager; }; diff --git a/cocos/gui/UILayoutDefine.h b/cocos/gui/UILayoutDefine.h index 0b772837ca..70ab70251f 100644 --- a/cocos/gui/UILayoutDefine.h +++ b/cocos/gui/UILayoutDefine.h @@ -26,7 +26,6 @@ #define __UILAYOUTDEFINE_H__ #include "cocos2d.h" -#include "ExtensionMacros.h" namespace gui { /**