I read the below link for reading from a file and have a doubt.
http://www.cocos2d-x.org/wiki/How_to_read_and_write_file_on_different_platforms
The code for Android and Windows is same whereas the code for IOS differs in just one function.
The function getFilePath() is different for IOS.(Please refer the link)
Can the getFilePath() function be combined and written as follows:
string FileOperation::getFilePath()
{
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/org.cocos2dx.application/tmpfile");
#endif
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
string path = [documentsDirectory UTF8String];
path.append( "/test.txt" );
#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;
}