Hi,
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 http://www.cocos2d-x.org/wiki/How_to_read_and_write_file_on_different_platforms.
std::string SaveGame::getFilePath()
{
std::string path("");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// 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.
path.append("/data/data/com.test.app/app_data");
mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
path.append("/data.bin");
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// You can save file in anywhere if you have the permision.
path.append("D:/tmpfile");
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
//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;
path.append("tmpfile");
#endif
#endif
return path;
}
It also states (backed up by this post http://cocos2d-x.org/forums/6/topics/21725) that you should use
CCFileUtils::sharedFileUtils()->getWriteablePath()
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?