Cocos2d: CCFileUtils: sharedFileUtils ()-) getFileData (szFile, & amp; quot; r & amp; quot;, & amp; bufferSize) different platform return values are different

Source: Internet
Author: User

Cocos2d: CCFileUtils: sharedFileUtils ()-) getFileData (szFile, & quot; r & quot;, & amp; bufferSize) different platform return values are different

String pathKey = CCFileUtils: sharedFileUtils ()-> fullPathForFilename (fileName); unsigned char * pBuffer = NULL; unsigned long bufferSize = 0; pBuffer = CCFileUtils: sharedFileUtils () -> getFileData (pathKey. c_str (), "rb", & bufferSize );

When I read a csv file using CCFileUtils: sharedFileUtils ()-> getFileData (szFile, "r", & bufferSize, it is found that the value of win32 platform is sometimes smaller than that of other platforms.

The reason is: CCFileUtils: getFileData (szFile, "r", & bufferSize) for a text file (wrap with \ r \ n)

The file size obtained by running in win32 is smaller. It seems that \ r has been deleted, but the complete size is obtained in OS.

Currently, you can only read text files in binary mode to ensure that the execution results on different platforms are identical.

Cocos2d: CCFileUtils: getFileData (szFile, "rb", & bufferSize );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.