Using getWriteablePath to copy a file

Using getWriteablePath to copy a file
0.0 0


I want to copy a PLIST file to the path returned by *CCFileUtils::getWriteablePath()* so that I will be able to edit that file. Is there a way this is possible? If so, how would I be able to save the new contents of this PLIST file?


Here is the code I am using to copy an MP3 file from the read-only part of the application (APK, or whatever) to the writable part.

You might be able to use it.

unsigned long tmpSize;
string fullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("data.mp3");
unsigned char* xmlData = CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "rb", &tmpSize);

FILE *fp = fopen(dbPath.c_str(), "wb");
fwrite(xmlData, tmpSize, 1, fp);

This reads and writes binary files. You’ll want to change the ‘rb’ and ‘wb’ to ‘r’ and ‘w’ probably.

There are many ways to copy one file to another file in C++