(1)文件拷贝到Document的目录下的封装
bool FengZhuang::FileCopy(const char * filename)
{
std::string path=CCFileUtils::sharedFileUtils()->getWritablePath();
std::string xmlPath=path+string(filename);
cout<<"xmlPath="<<xmlPath<<endl;
std::string path2=CCFileUtils::sharedFileUtils()->fullPathForFilename(filename);
if(!CCFileUtils::sharedFileUtils()->isFileExist(xmlPath))
{
const char * file_path=CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(path2.c_str(), "");
unsigned long size;
char * pFileContent=(char*)CCFileUtils::sharedFileUtils()->getFileData(file_path, "r", &size);
CCLOG("%s",pFileContent);
FILE * file=fopen(xmlPath.c_str(), "w");
if(file)
{
fputs(pFileContent,file);
fclose(file);
}
return true;
}
return false;
}
bool FileCopy2(const char * sourcePath,const char* destinationPath)
{
if(!CCFileUtils::sharedFileUtils()->isFileExist(destinationPath))
{
const char * file_path=CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(sourcePath, "");
unsigned long size;
char * pFileContent=(char*)CCFileUtils::sharedFileUtils()->getFileData(file_path, "r", &size);
CCLOG("%s",pFileContent);
FILE * file=fopen(destinationPath, "w");
if(file)
{
fputs(pFileContent,file);
fclose(file);
}
return true;
}
return false;
}