Changed: CFile::copyFile takes now 2 std::string as parameters
This commit is contained in:
parent
575f577dac
commit
082676ea80
22 changed files with 36 additions and 37 deletions
|
@ -651,7 +651,7 @@ struct CFile
|
|||
* \param failIfExists If the destination file exists, nothing is done, and it returns false.
|
||||
* \return true if the copy succeeded
|
||||
*/
|
||||
static bool copyFile(const char *dest, const char *src, bool failIfExists = false, class IProgressCallback *progress = NULL);
|
||||
static bool copyFile(const std::string &dest, const std::string &src, bool failIfExists = false, class IProgressCallback *progress = NULL);
|
||||
|
||||
/** Compare 2 files
|
||||
* \return true if both files exist and the files have same timestamp and size
|
||||
|
|
|
@ -588,7 +588,7 @@ bool COFile::open(const std::string &path, bool append, bool text, bool useTempF
|
|||
if (append && useTempFile && CFile::fileExists(_FileName))
|
||||
{
|
||||
// open fails if can't copy original content
|
||||
if (!CFile::copyFile(_TempFileName.c_str(), _FileName.c_str()))
|
||||
if (!CFile::copyFile(_TempFileName, _FileName))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2099,10 +2099,9 @@ void CFile::checkFileChange (TTime frequency)
|
|||
}
|
||||
}
|
||||
|
||||
static bool CopyMoveFile(const char *dest, const char *src, bool copyFile, bool failIfExists = false, IProgressCallback *progress = NULL)
|
||||
static bool CopyMoveFile(const std::string &dest, const std::string &src, bool copyFile, bool failIfExists = false, IProgressCallback *progress = NULL)
|
||||
{
|
||||
if (!dest || !src) return false;
|
||||
if (!strlen(dest) || !strlen(src)) return false;
|
||||
if (dest.empty() || src.empty()) return false;
|
||||
std::string sdest = CPath::standardizePath(dest,false);
|
||||
std::string ssrc = CPath::standardizePath(src,false);
|
||||
|
||||
|
@ -2199,7 +2198,7 @@ static bool CopyMoveFile(const char *dest, const char *src, bool copyFile, bool
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CFile::copyFile(const char *dest, const char *src, bool failIfExists /*=false*/, IProgressCallback *progress)
|
||||
bool CFile::copyFile(const std::string &dest, const std::string &src, bool failIfExists /*=false*/, IProgressCallback *progress)
|
||||
{
|
||||
return CopyMoveFile(dest, src, true, failIfExists, progress);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ int main(int argc, char *argv[])
|
|||
// if fail to find a valid filter, just do a copy
|
||||
if(j==LodFilters.size())
|
||||
{
|
||||
CFile::copyFile(pathNameOut.c_str(), pathNameIn.c_str());
|
||||
CFile::copyFile(pathNameOut, pathNameIn);
|
||||
NLMISC::InfoLog->displayRaw("Processing %s - Copied\n", fileNameIn.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ void filterRyzomBug(const char *dirSrc, const char *dirDst, uint patchVersionWan
|
|||
CFile::createDirectory(dirDest);
|
||||
|
||||
// copy near the dmp
|
||||
CFile::copyFile((dirDest + "/" + fileNoDir).c_str(), fileFullPath.c_str());
|
||||
CFile::copyFile(dirDest + "/" + fileNoDir, fileFullPath);
|
||||
|
||||
|
||||
// copy all the .dmp in a new dir
|
||||
|
@ -136,7 +136,7 @@ void filterRyzomBug(const char *dirSrc, const char *dirDst, uint patchVersionWan
|
|||
for(uint j=0;j<dmpList.size();j++)
|
||||
{
|
||||
string dmpNoDir= CFile::getFilename(dmpList[j]);
|
||||
CFile::copyFile((dirDest+ "/" + dmpNoDir).c_str(), dmpList[j].c_str());
|
||||
CFile::copyFile(dirDest+ "/" + dmpNoDir, dmpList[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ private:
|
|||
fclose(fp);
|
||||
fp = NULL;
|
||||
|
||||
NLMISC::CFile::copyFile(_DstFile.c_str(), _SrcFile.c_str(), false);
|
||||
NLMISC::CFile::copyFile(_DstFile, _SrcFile, false);
|
||||
|
||||
// verify the resulting file
|
||||
fp = fopen(_DstFile.c_str(), "rb");
|
||||
|
|
|
@ -1307,7 +1307,7 @@ void CPatchManager::downloadFile (const string &source, const string &dest, NLMI
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!NLMISC::CFile::copyFile(dest.c_str(), source.c_str(), false, progress))
|
||||
if (!NLMISC::CFile::copyFile(dest, source, false, progress))
|
||||
{
|
||||
if (errno == 28)
|
||||
{
|
||||
|
|
|
@ -249,7 +249,7 @@ bool CBNPFile::addVersion(const std::string& bnpDirectory, const std::string& /*
|
|||
|
||||
// copy the file to create a new reference file...
|
||||
// NLMISC::CSString refFileName= NLMISC::CSString(refDirectory+_FileName).replace(".",NLMISC::toString("_%05u.",version.getPackageVersionNumber()).c_str());
|
||||
// NLMISC::CFile::copyFile(refFileName.c_str(),fullFileName.c_str());
|
||||
// NLMISC::CFile::copyFile(refFileName, fullFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -412,7 +412,7 @@ IFileAccess::TReturnCode CWriteFile::execute(CFileAccessManager& manager)
|
|||
bool fileBackuped = true;
|
||||
if (fileExists && BackupFile)
|
||||
{
|
||||
if (!NLMISC::CFile::copyFile( (getBackupFileName(Filename)+".backup").c_str(), (getBackupFileName(Filename)).c_str()))
|
||||
if (!NLMISC::CFile::copyFile( getBackupFileName(Filename)+".backup", getBackupFileName(Filename)))
|
||||
{
|
||||
fileBackuped = false;
|
||||
if (checkFailureMode(MajorFailureIfFileUnbackupable))
|
||||
|
|
|
@ -377,7 +377,7 @@ static void cbSaveCheckFile( CMessage& msgin, const std::string &serviceName, NL
|
|||
|
||||
try
|
||||
{
|
||||
NLMISC::CFile::copyFile( ( msg.FileName + string(".backup") ).c_str(), msg.FileName.c_str() );
|
||||
NLMISC::CFile::copyFile( msg.FileName + string(".backup"), msg.FileName );
|
||||
}
|
||||
catch( Exception &e )
|
||||
{
|
||||
|
|
|
@ -338,7 +338,7 @@ void cbRestoreSave(CMemStream &msgin, TSockId host)
|
|||
|
||||
bool success;
|
||||
|
||||
success = CFile::copyFile(outputfile.c_str(), file.c_str(), false);
|
||||
success = CFile::copyFile(outputfile, file, false);
|
||||
|
||||
CMemStream msgout;
|
||||
uint32 fake = 0;
|
||||
|
@ -431,7 +431,7 @@ void cbCopyOverSave(CMemStream &msgin, TSockId host)
|
|||
strFindReplace(outputfile, string("$charid"), charid);
|
||||
strFindReplace(outputfile, string("$ext"), extensions[i]);
|
||||
|
||||
success = CFile::copyFile(outputfile.c_str(), file.c_str(), false);
|
||||
success = CFile::copyFile(outputfile, file, false);
|
||||
|
||||
if (!success)
|
||||
result = "Failed to copy "+file+" over "+outputfile+".";
|
||||
|
|
|
@ -528,8 +528,8 @@ bool loadAndResaveCheckCharacters( const std::vector<string>& files, NLMISC::CLo
|
|||
{
|
||||
id.Chars[i].Backup = id.Chars[i].File + ".tmp";
|
||||
CFile::copyFile(
|
||||
id.Chars[i].Backup.c_str(),
|
||||
id.Chars[i].File.c_str());
|
||||
id.Chars[i].Backup,
|
||||
id.Chars[i].File);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,8 +596,8 @@ bool loadAndResaveCheckCharacters( const std::vector<string>& files, NLMISC::CLo
|
|||
for (i=0; i<id.Chars.size(); ++i)
|
||||
{
|
||||
CFile::copyFile(
|
||||
id.Chars[i].File.c_str(),
|
||||
id.Chars[i].Backup.c_str());
|
||||
id.Chars[i].File,
|
||||
id.Chars[i].Backup);
|
||||
CFile::deleteFile(id.Chars[i].Backup);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,9 +133,9 @@ void CPlayer::checkCrashMarker()
|
|||
// if (CFile::isExists(fileName+".last_good"))
|
||||
// {
|
||||
// nlwarning(" Restoring last good version...");
|
||||
// CFile::copyFile(fileName.c_str(), (fileName+".last_good").c_str());
|
||||
// CFile::copyFile(fileName, fileName+".last_good");
|
||||
// nlwarning(" And copying the backup for comparison with bad file...");
|
||||
// CFile::copyFile((fileName+".before_wipe").c_str(), (fileName+".last_good").c_str());
|
||||
// CFile::copyFile(fileName+".before_wipe", fileName+".last_good");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
@ -174,9 +174,9 @@ bool wipeAndRestore(const std::string &fileName)
|
|||
//if (CFile::isExists(fileName+".last_good"))
|
||||
//{
|
||||
// nlwarning(" Restoring last good version...");
|
||||
// CFile::copyFile(fileName.c_str(), (fileName+".last_good").c_str());
|
||||
// CFile::copyFile(fileName, fileName+".last_good");
|
||||
// nlwarning(" And copying the backup for comparison with bad file...");
|
||||
// CFile::copyFile((fileName+".before_wipe").c_str(), (fileName+".last_good").c_str());
|
||||
// CFile::copyFile(fileName+".before_wipe", fileName+".last_good");
|
||||
//
|
||||
// // restore success
|
||||
// return true;
|
||||
|
|
|
@ -289,7 +289,7 @@ void CServerPatchApplier::_patchUpFromLive(uint32 liveVersion, uint32 installReq
|
|||
if (patchIdx==it->second.size())
|
||||
{
|
||||
nlinfo("COPY: %s from %s",(_Directories.installDirectoryName()+it->first).c_str(),(_Directories.liveDirectoryName()+it->first).c_str());
|
||||
NLMISC::CFile::copyFile((_Directories.installDirectoryName()+it->first).c_str(),(_Directories.liveDirectoryName()+it->first).c_str());
|
||||
NLMISC::CFile::copyFile(_Directories.installDirectoryName()+it->first,_Directories.liveDirectoryName()+it->first);
|
||||
untarIfNeeded(_Directories.installDirectoryName()+it->first);
|
||||
continue;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ void CServerPatchApplier::_patchDownFromLive(uint32 liveVersion, uint32 installR
|
|||
if (needBackPatchSet.find(it->first)==needBackPatchSet.end())
|
||||
{
|
||||
nlinfo("COPY: %s => %s",(_Directories.installDirectoryName()+it->first).c_str(),(_Directories.liveDirectoryName()+it->first).c_str());
|
||||
NLMISC::CFile::copyFile((_Directories.installDirectoryName()+it->first).c_str(),(_Directories.liveDirectoryName()+it->first).c_str());
|
||||
NLMISC::CFile::copyFile(_Directories.installDirectoryName()+it->first,_Directories.liveDirectoryName()+it->first);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -827,7 +827,7 @@ void CServerPatchApplier::_requestDownload(const NLMISC::CSString& domainName,co
|
|||
if (fileInfo.Checksum==liveFileInfo.Checksum)
|
||||
{
|
||||
// try copying the file and return if we succeeded (we don't need to send a download request)
|
||||
bool ok=NLMISC::CFile::copyFile(fileNameInNext.c_str(),fileNameInLive.c_str());
|
||||
bool ok=NLMISC::CFile::copyFile(fileNameInNext,fileNameInLive);
|
||||
if (ok)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ void CServerPatchBridge::requestFileData(NLNET::IModuleProxy *sender, const NLMI
|
|||
CSString rootDirectory= getRepositoryDirectory()->getRootDirectory();
|
||||
CSString fullFileName= rootDirectory+fileInfo.FileName;
|
||||
NLMISC::CFile::createDirectoryTree(NLMISC::CFile::getPath(fullFileName));
|
||||
bool ok= NLMISC::CFile::copyFile(fullFileName.c_str(),(rootDirectory+itInfo.FileName).c_str());
|
||||
bool ok= NLMISC::CFile::copyFile(fullFileName,rootDirectory+itInfo.FileName);
|
||||
WARN_IF(!ok,"Failed to copy file: '"+itInfo.FileName+" to '"+fileInfo.FileName+"'");
|
||||
|
||||
// force our repository to update it's info concerning the file that we just copied and rebuild our info vector
|
||||
|
|
|
@ -122,7 +122,7 @@ bool CReferenceBuilder::internalBuild(const std::string& rootRefPath,
|
|||
CTimestamp maxstamp(maxtimestamp);
|
||||
|
||||
// copy xml description from previous directory to new
|
||||
if (!CFile::copyFile((next+"description.xml").c_str(), (previous+"description.xml").c_str(), true))
|
||||
if (!CFile::copyFile(next+"description.xml", previous+"description.xml", true))
|
||||
{
|
||||
nlwarning("CReferenceBuilder::build(): failed to copy 'description.xml' from '%s' to '%s'", previous.c_str(), next.c_str());
|
||||
return false;
|
||||
|
@ -151,7 +151,7 @@ bool CReferenceBuilder::internalBuild(const std::string& rootRefPath,
|
|||
string file = CFile::getFilename(files[i]);
|
||||
|
||||
// copy from old to new directory
|
||||
if (!CFile::copyFile((next+file).c_str(), (previous+file).c_str(), true))
|
||||
if (!CFile::copyFile(next+file, previous+file, true))
|
||||
{
|
||||
nlwarning("CReferenceBuilder::build(): failed to copy '%s' from '%s' to '%s'", file.c_str(), previous.c_str(), next.c_str());
|
||||
return false;
|
||||
|
|
|
@ -1596,7 +1596,7 @@ bool CDatabase::buildDelta(const CTimestamp& starttime, const CTimestamp& endtim
|
|||
std::string statePath = _Reference.getRootPath();
|
||||
std::string stateName = CDatabaseState::fileName();
|
||||
if (CFile::fileExists(statePath+stateName) &&
|
||||
!CFile::copyFile((statePath+"previous_"+stateName).c_str(), (statePath+stateName).c_str(), false))
|
||||
!CFile::copyFile(statePath+"previous_"+stateName, statePath+stateName, false))
|
||||
{
|
||||
PDS_WARNING("buildDelta(): failed copy state file to backup previous_state");
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ NLMISC_CATEGORISED_COMMAND(utils,copyFile,"copy a file","<src> <dest>")
|
|||
if (args.size()!=2)
|
||||
return false;
|
||||
|
||||
NLMISC::CFile::copyFile(args[1].c_str(),args[0].c_str());
|
||||
NLMISC::CFile::copyFile(args[1],args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -842,19 +842,19 @@ bool CMissionCompiler::publishFiles(const std::string &serverPathPrim, const std
|
|||
string textFile = CPath::standardizePath(serverPathText) + "phrase_rites_wk.txt";
|
||||
includeText(textFile, string("#include \"") + src + string("\"\n"));
|
||||
dst = CPath::standardizePath(serverPathText) + src;
|
||||
NLMISC::CFile::copyFile(dst.c_str(), src.c_str());
|
||||
NLMISC::CFile::copyFile(dst, src);
|
||||
|
||||
// local
|
||||
textFile = CPath::standardizePath(localPathText) + "phrase_rites_wk.txt";
|
||||
includeText(textFile, string("#include \"") + src + string("\"\n"));
|
||||
dst = CPath::standardizePath(localPathText) + src;
|
||||
NLMISC::CFile::copyFile(dst.c_str(), src.c_str());
|
||||
NLMISC::CFile::copyFile(dst, src);
|
||||
}
|
||||
else
|
||||
{
|
||||
// primitive file : copy to server
|
||||
dst = CPath::standardizePath(serverPathPrim) + string(src, n, src.size());
|
||||
NLMISC::CFile::copyFile(dst.c_str(), src.c_str());
|
||||
NLMISC::CFile::copyFile(dst, src);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -249,7 +249,7 @@ void CPackageDescription::updateIndexFileList(CBNPFileSet& packageIndex) const
|
|||
// if the ref file doesn't exist then create it by copying the original
|
||||
if (NLMISC::CFile::fileExists(_BnpDirectory+fileName) && !NLMISC::CFile::fileExists(_BnpDirectory+refName))
|
||||
{
|
||||
NLMISC::CFile::copyFile((_BnpDirectory+refName).c_str(),(_BnpDirectory+fileName).c_str());
|
||||
NLMISC::CFile::copyFile(_BnpDirectory+refName,_BnpDirectory+fileName);
|
||||
nlassert(NLMISC::CFile::getFileSize(_BnpDirectory+refName)== NLMISC::CFile::getFileSize(_BnpDirectory+fileName));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2457,7 +2457,7 @@ int updatePhraseWork()
|
|||
std::string newFile = saveDir + outputResult[firstFile].second;
|
||||
std::string oldFile = outputResult[firstFile].second;
|
||||
CFile::createDirectoryTree(CFile::getPath(newFile));
|
||||
if ( CFile::copyFile(newFile.c_str(), oldFile.c_str()) )
|
||||
if ( CFile::copyFile(newFile, oldFile) )
|
||||
{
|
||||
|
||||
patchWorkFile(updatedPhrases, newFile);
|
||||
|
|
Loading…
Reference in a new issue