Reading from File in cocos2dx C++

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;
}

Why is this the drive letter hard-coded in here? It would introduce major issues, if there is no drive letter D.

We have a bit of info on accessing the file system: http://cocos2d-x.org/programmersguide/14/index.html#file-system-access

There shouldn’t be a need to do any Objective-C amongst your c++ for other platforms. We handle everything in a cross-platform manner.

Thank you for the link.

Is there a sample code for File I/O?

What if I have an XML file and want to read data from that XML File?

The link does not work.

https://docs.cocos2d-x.org/cocos2d-x/en/advanced_topics/filesystem.html

I’ll add an nginx re-write rule.

Edit: actually the original link works for me…