cocos2dx中使用的xml 移植到真机可用
ssize_t size=0;
const char *pFileContent=NULL;
pFileContent=(char*) FileUtils::sharedFileUtils()->getFileData( "data/string.xml" , "r", &size);
tinyxml2::XMLDocument doc ;
doc.Parse(pFileContent);
auto pRoot = doc.RootElement( ) ;
for ( auto pElem = pRoot->FirstChildElement( ) ; pElem != 0 ; pElem = pElem->NextSiblingElement() )
{
stringList pElem->Attribute( "Key" ) ] = pElem->Attribute( "Value" ) ;
}
```
cocos2dx中使用的sqlite3 移植到真机可用 (必须使用二进制数据存储 ,否则容易出错)
void copyData(const char* pFileName)
{
std::string strPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(pFileName);
ssize_t len = 0;
unsigned char *data = NULL;
int b=CCFileUtils::sharedFileUtils()->isFileExist(strPath);
data = CCFileUtils::sharedFileUtils()->getFileData(strPath.c_str(),"rb+",&len);
std::string destPath = CCFileUtils::sharedFileUtils()->getWritablePath();
destPath += pFileName;
FILE *fp = fopen(destPath.c_str(),"wb+");
fwrite(data,sizeof(char),len,fp);
fclose(fp);
delete ]data;
data = NULL;
}
```
交流qq:1024461366