Proper usage of CCFileUtils

Proper usage of CCFileUtils
0.0 0


Let me first start by saying that you are doing a great job with this project. Keep it up:)

I have a question regarding the proper usage of the CCFileUtils. I am trying to achieve two things:

  1. Get the Document folder of the iphone sand box in a way that will not force me to use #ifdef when I am compiling for windows. I don’t see any relevant interface that can help me with that.
  2. Get a subfolder of a resources, as my images are ordered in a folder structure within the app resources. Here I ran into some difficulties when I tried to use fullPathFromRelativePath. It returns with the original value I send as a parameter.

The API reference is not updated with this methods.



CCFileUtils is designed for the platforms without the concept of “relative path”, such as linux & uphone. It doesn’t work or iOS sandbox.
If you want to read the resources in a subfolder, you can easily use “myfolder/myimage.png” in cocos2d-x cross-platform games. But you need to do nothing with CCFileUtils on iOS.

for example

#if defined(CCX_UNDER_IPHONE)
    // you need to do nothing on iOS
#elif defined(CCX_UNDER_UPHONE)

    // call realtive path in cross-platform games
    CCSprite* sprite = CCSprite:spriteWithFile("imgfolder/happychristmas.png");


Thanks, this answered my question.