mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4125 from minggo/fix-compiling-error
[ci skip]fix compiling erros on Android
This commit is contained in:
commit
237f7a7839
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#define __UILAYOUTDEFINE_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "ExtensionMacros.h"
|
||||
|
||||
namespace gui {
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue