[HHHHHHHelp]How can i do files I/O opration with CCFileUtils::getFileData(), are there any other ways?[Help]

when i programing on iOS Xcode platform with cocos2d-x used CCFileUtils::getFileData(),always got error like ‘call to non-static member’.
well, can anyone tell me how to done with this problem?

And, other question for what choices func to do file I/O better?

demand for the code can portable on anywhere!

for example:
1 . with C standard library functions
FILE * p and so on.
2 . with getFileData() in Cocos2d-x

my english is not very good, please forgive me.

thx a lot,thx everybody

Qian Lee wrote:

when i programing on iOS Xcode platform with cocos2d-x used CCFileUtils::getFileData(),always got error like ‘call to non-static member’.
well, can anyone tell me how to done with this problem?
>

CCFileUtils::sharedFileUtils()->getFileData()

byez

Stefano

And, other question for what choices func to do file I/O better?
>
demand for the code can portable on anywhere!
>
for example:
1 . with C standard library functions
FILE * p and so on.
2 . with getFileData() in Cocos2d-x
>
my english is not very good, please forgive me.
>
thx a lot,thx everybody

Qian Lee wrote:

when i programing on iOS Xcode platform with cocos2d-x used CCFileUtils::getFileData(),always got error like ‘call to non-static member’.
It should be CCFileUtils::sharedFileUtils -> getFileData;

And, other question for what choices func to do file I/O better?
CCUserDefault provides a simple interface for File I/O.
You can also try pugixml. It’s light-weight and easy to use. I believe many people in this forum are using pugixml

I’m having the same problems with a library I’m trying to use, that uses fopen for opening files. (config files)

unfortunatelly we cannot open a file with fopen from an apk (because all assets are compressed and you don’t have access to the file itself)

Possible solutions.

  1. Rewrite fopen with this method http://www.50ply.com/blog/2013/01/19/loading-compressed-android-assets-with-file-pointer/
  2. Unpack selected files at first start up of the apk to /data/data/ and load from user data dir
  3. Modify library to use CCFileUtils::sharedFileUtils() > getFileData; , extract the the file to memory and then use some open_memstream hack
    1
    > have problems with cocos2d, because you rewrite “ALL fopen” including the calls you don’t want to rewrite, for example on the CCFileUtils, or when you want to write a file for writing
    3 > I tryed this approach, but I’m having problem reading with fgets and open_memstream
    2
    > this is my next aproach.

NOTE for cocos2d developers.
It’s possible to have an fopen hack that tries to open the desired file using the hack first, and if not try the real fopen? Selecting the real fopen on write too.

For my settings.XML file, I made a template and saved it on my project. Then when it is deployed on android, it is copied to whatever CCFileUtils::getWriteablePath() returns.