Reading/Writing save game files

Reading/Writing save game files
0.0 0



I’m a bit of noob on cross platform, though I have a good understanding on the Android platform.

Just for testing reading and writing save games. I did this from

std::string SaveGame::getFilePath()
    std::string path("");

    // In android, every programe has a director under /data/data.
    // The path is /data/data/ + start activity package name.
    // You can save application specific data here.
    mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);

    // You can save file in anywhere if you have the permision.

    //path = cocos2d::CCApplication::sharedApplication().getAppDataPath();

#ifdef _TRANZDA_VM_
    // If runs on WoPhone simulator, you should insert "D:/Work7" at the
    // begin. We will fix the bug in no far future.
    path = "D:/Work7" + path;


    return path;

It also states (backed up by this post that you should use


But I get “error: ‘CCFileUtils’ has not been declared”

Can anyone confirm what the best way to get a writeable path cross platform is?

Or what is wrong with CCFileUtils in v2.1.4?


Try ‘cocos2d::CCFileUtils::sharedFileUtils()->getWriteablePath()’ or look to make sure you’re not missing an include or namespace.


You can also use the CCUserDefault :

Remember to use the `flush()` method to actually write the data to file.


Cory Trese wrote:

Try ‘cocos2d::CCFileUtils::sharedFileUtils()->getWriteablePath()’ or look to make sure you’re not missing an include or namespace.

Doh! Missed the namespace, I think I was a bit fried when when is posted this! Thanks for your help.