cocos2dx 复制数据到文件夹中

现在又一个数据库文件在资源目录下,假设名为save.db,那么怎么通过代码把他复制到其他目录中呢?例如Debug.win32下。下面直接贴出代码:

 

    std::string strPath = FileUtils::getInstance()->fullPathForFilename("nf_static.db");
    ssize_t len = 0;
    unsigned char* data = NULL;
    data = FileUtils::sharedFileUtils()->getFileData(strPath.c_str(), "r", &len);

    std::string destPath = FileUtils::sharedFileUtils()->getWritablePath();
    destPath += "nf_static.db";

    FILE *pFp = fopen(destPath.c_str(), "w+");
    fwrite(data, sizeof(char), len, pFp);
    fclose(pFp);
    delete[]data;
    data = NULL;

 

打开目录,可以看见复制进来的文件

 

posted @ 2014-12-04 15:04  烂橘子  阅读(302)  评论(0编辑  收藏  举报