From 808f7b2c309a282f85960ea9ff3ff0468e9116e2 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 20 Feb 2016 17:56:25 +0100 Subject: [PATCH] Use new wrapper insteaf of fopen, issue #261 --- code/nel/include/nel/misc/debug.h | 2 +- .../opengl/driver_opengl_vertex_program.cpp | 2 +- code/nel/src/gui/group_html.cpp | 4 ++-- code/nel/src/misc/async_file_manager.cpp | 4 ++-- code/nel/src/misc/big_file.cpp | 16 ++++++++-------- code/nel/src/misc/config_file/config_file.cpp | 2 +- code/nel/src/misc/cpu_time_stat.cpp | 4 ++-- code/nel/src/misc/diff_tool.cpp | 2 +- code/nel/src/misc/displayer.cpp | 2 +- code/nel/src/misc/eid_translator.cpp | 2 +- code/nel/src/misc/file.cpp | 4 ++-- code/nel/src/misc/path.cpp | 10 +++++----- code/nel/src/misc/sha1.cpp | 2 +- code/nel/src/misc/sstring.cpp | 4 ++-- code/nel/src/misc/xml_pack.cpp | 6 +++--- code/nel/src/net/email.cpp | 4 ++-- code/nel/src/net/service.cpp | 4 ++-- .../tools/nel_unit_test/ut_ligo_primitive.h | 2 +- code/nel/tools/nel_unit_test/ut_misc_file.h | 13 +++++++------ code/ryzom/client/src/cdb_synchronised.cpp | 19 +++++++++++++------ code/ryzom/client/src/client_cfg.cpp | 2 +- code/ryzom/client/src/commands.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- code/ryzom/client/src/login_patch.cpp | 12 ++++++------ code/ryzom/client/src/login_xdelta.cpp | 6 +++--- code/ryzom/client/src/permanent_ban.cpp | 2 +- .../src/r2/dmc/client_edition_module.cpp | 6 +++--- code/ryzom/client/src/seven_zip/seven_zip.cpp | 2 +- code/ryzom/client/src/sheet_manager.cpp | 2 +- code/ryzom/common/src/game_share/bmp4image.h | 2 +- .../common/src/game_share/persistent_data.cpp | 2 +- 31 files changed, 78 insertions(+), 70 deletions(-) diff --git a/code/nel/include/nel/misc/debug.h b/code/nel/include/nel/misc/debug.h index 8d2483e4e..54e22880d 100644 --- a/code/nel/include/nel/misc/debug.h +++ b/code/nel/include/nel/misc/debug.h @@ -229,7 +229,7 @@ void setCrashAlreadyReported(bool state); *\code void function(char *filename) { - FILE *fp = fopen (filename, "r"); + FILE *fp = nlfopen (filename, "r"); if (fp==NULL) { nlerror("file not found"); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp index 1c06ece9a..93d281fec 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp @@ -1672,7 +1672,7 @@ bool CDriverGL::compileEXTVertexShader(CVertexProgram *program) } /* - FILE *f = fopen(getLogDirectory() + "test.txt", "wb"); + FILE *f = nlfopen(getLogDirectory() + "test.txt", "wb"); if (f) { std::string vpText; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index a0f65827e..f72198ec7 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -304,7 +304,7 @@ namespace NLGUI return; } - FILE *fp = fopen (tmpdest.c_str(), "wb"); + FILE *fp = nlfopen (tmpdest, "wb"); if (fp == NULL) { curl_easy_cleanup(curl); @@ -411,7 +411,7 @@ namespace NLGUI return false; } - FILE *fp = fopen (tmpdest.c_str(), "wb"); + FILE *fp = nlfopen (tmpdest, "wb"); if (fp == NULL) { curl_easy_cleanup(curl); diff --git a/code/nel/src/misc/async_file_manager.cpp b/code/nel/src/misc/async_file_manager.cpp index 366237722..d1653e6ce 100644 --- a/code/nel/src/misc/async_file_manager.cpp +++ b/code/nel/src/misc/async_file_manager.cpp @@ -207,7 +207,7 @@ CAsyncFileManager::CFileLoad::CFileLoad (const std::string& sFileName, uint8 **p // *************************************************************************** void CAsyncFileManager::CFileLoad::run (void) { - FILE *f = fopen (_FileName.c_str(), "rb"); + FILE *f = nlfopen (_FileName, "rb"); if (f != NULL) { uint8 *ptr; @@ -253,7 +253,7 @@ void CAsyncFileManager::CMultipleFileLoad::run (void) { for (uint32 i = 0; i < _FileNames.size(); ++i) { - FILE *f = fopen (_FileNames[i].c_str(), "rb"); + FILE *f = nlfopen (_FileNames[i], "rb"); if (f != NULL) { uint8 *ptr; diff --git a/code/nel/src/misc/big_file.cpp b/code/nel/src/misc/big_file.cpp index 1de1c2b73..a458b602d 100644 --- a/code/nel/src/misc/big_file.cpp +++ b/code/nel/src/misc/big_file.cpp @@ -136,7 +136,7 @@ bool CBigFile::add (const std::string &sBigFileName, uint32 nOptions) CHandleFile &handle= _ThreadFileArray.get(bnp.ThreadFileId); // Open the big file. - handle.File = fopen (sBigFileName.c_str(), "rb"); + handle.File = nlfopen (sBigFileName, "rb"); if (handle.File == NULL) return false; @@ -197,7 +197,7 @@ bool CBigFile::BNP::readHeader() // Only external use if (InternalUse || BigFileName.empty()) return false; - FILE *f = fopen (BigFileName.c_str(), "rb"); + FILE *f = nlfopen (BigFileName, "rb"); if (f == NULL) return false; bool res = readHeader(f); @@ -348,7 +348,7 @@ bool CBigFile::BNP::appendHeader() // Only external use if (InternalUse || BigFileName.empty()) return false; - FILE *f = fopen (BigFileName.c_str(), "ab"); + FILE *f = nlfopen (BigFileName, "ab"); if (f == NULL) return false; uint32 nNbFile = (uint32)SFiles.size(); @@ -438,10 +438,10 @@ bool CBigFile::BNP::appendFile(const std::string &filename) SFiles.push_back(ftmp); OffsetFromBeginning += ftmp.Size; - FILE *f1 = fopen(BigFileName.c_str(), "ab"); + FILE *f1 = nlfopen(BigFileName, "ab"); if (f1 == NULL) return false; - FILE *f2 = fopen(filename.c_str(), "rb"); + FILE *f2 = nlfopen(filename, "rb"); if (f2 == NULL) { fclose(f1); @@ -473,7 +473,7 @@ bool CBigFile::BNP::unpack(const std::string &sDestDir, TUnpackProgressCallback // Only external use if (InternalUse || BigFileName.empty()) return false; - FILE *bnp = fopen (BigFileName.c_str(), "rb"); + FILE *bnp = nlfopen (BigFileName, "rb"); if (bnp == NULL) return false; @@ -506,7 +506,7 @@ bool CBigFile::BNP::unpack(const std::string &sDestDir, TUnpackProgressCallback return false; } - out = fopen (filename.c_str(), "wb"); + out = nlfopen (filename, "wb"); if (out != NULL) { nlfseek64 (bnp, rBNPFile.Pos, SEEK_SET); @@ -681,7 +681,7 @@ FILE* CBigFile::getFile (const std::string &sFileName, uint32 &rFileSize, */ if(handle.File== NULL) { - handle.File = fopen (bnp->BigFileName.c_str(), "rb"); + handle.File = nlfopen (bnp->BigFileName, "rb"); if (handle.File == NULL) { nlwarning ("bnp: can't fopen big file '%s' error %d '%s'", bnp->BigFileName.c_str(), errno, strerror(errno)); diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index c969f614d..093992487 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -600,7 +600,7 @@ void CConfigFile::save () const // Avoid any problem, Force Locale to default setlocale(LC_ALL, "C"); - FILE *fp = fopen (getFilename().c_str (), "w"); + FILE *fp = nlfopen (getFilename(), "w"); if (fp == NULL) { nlwarning ("CF: Couldn't create %s file", getFilename().c_str ()); diff --git a/code/nel/src/misc/cpu_time_stat.cpp b/code/nel/src/misc/cpu_time_stat.cpp index 6441a8b45..455104b25 100644 --- a/code/nel/src/misc/cpu_time_stat.cpp +++ b/code/nel/src/misc/cpu_time_stat.cpp @@ -42,7 +42,7 @@ bool CCPUTimeStat::getCPUTicks(uint64& user, uint64& nice, uint64& system, uint6 #ifdef NL_OS_UNIX const char* statfile = "/proc/stat"; - FILE* f = fopen(statfile, "r"); + FILE* f = nlfopen(statfile, "r"); if (f == NULL) return false; @@ -66,7 +66,7 @@ bool CCPUTimeStat::getPIDTicks(uint64& utime, uint64& stime, uint64& cutime, uin #ifdef NL_OS_UNIX std::string statfile = NLMISC::toString("/proc/%u/stat", pid); - FILE* f = fopen(statfile.c_str(), "r"); + FILE* f = nlfopen(statfile, "r"); if (f == NULL) return false; diff --git a/code/nel/src/misc/diff_tool.cpp b/code/nel/src/misc/diff_tool.cpp index 15a91cdb8..f57746b1a 100644 --- a/code/nel/src/misc/diff_tool.cpp +++ b/code/nel/src/misc/diff_tool.cpp @@ -93,7 +93,7 @@ bool loadStringFile(const std::string filename, vector &stringInfos return true; } */ -/* FILE *fp = fopen(filename.c_str(), "rb"); +/* FILE *fp = nlfopen(filename, "rb"); if (fp == NULL) { diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 60fa244b6..159a3d6b5 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -491,7 +491,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes if (_FilePointer == (FILE*)1) { - _FilePointer = fopen (_FileName.c_str(), "at"); + _FilePointer = nlfopen (_FileName, "at"); if (_FilePointer == NULL) printf ("Can't open log file '%s': %s\n", _FileName.c_str(), strerror (errno)); } diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index acf4046e5..591b9db7a 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -445,7 +445,7 @@ void cbInvalidEntityNamesFilename(const std::string &invalidEntityNamesFilename) return; } - FILE *fp = fopen (fn.c_str(), "r"); + FILE *fp = nlfopen (fn, "r"); if (fp == NULL) { nlwarning ("EIT: Can't load filename '%s' for invalid entity names filename", fn.c_str()); diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index 00a1823ef..01c417635 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -243,7 +243,7 @@ bool CIFile::open(const std::string &path, bool text) _IsInXMLPackFile = false; _BigFileOffset = 0; _AlwaysOpened = false; - _F = fopen (path.c_str(), mode); + _F = nlfopen (path, mode); if (_F != NULL) { /* @@ -598,7 +598,7 @@ bool COFile::open(const std::string &path, bool append, bool text, bool useTempF return false; } - _F=fopen(fileToOpen.c_str(), mode); + _F = nlfopen(fileToOpen, mode); return _F!=NULL; } diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index ee47fd494..c473bf29c 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1269,7 +1269,7 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, // Open and read the big file header nlassert(!_MemoryCompressed); - FILE *Handle = fopen (sBigFilename.c_str(), "rb"); + FILE *Handle = nlfopen (sBigFilename, "rb"); if (Handle == NULL) { nlwarning ("PATH: CPath::addSearchBigFile(%s, %d, %d): can't open file, skip it", sBigFilename.c_str(), recurse, alternative); @@ -1421,7 +1421,7 @@ void CFileContainer::addSearchXmlpackFile (const string &sXmlpackFilename, bool } // Open and read the xmlpack file header - FILE *Handle = fopen (sXmlpackFilename.c_str(), "rb"); + FILE *Handle = nlfopen (sXmlpackFilename, "rb"); if (Handle == NULL) { nlwarning ("PATH: CPath::addSearchXmlpackFile(%s, %d, %d): can't open file, skip it", sXmlpackFilename.c_str(), recurse, alternative); @@ -1950,7 +1950,7 @@ bool CFile::isExists (const string &filename) bool CFile::createEmptyFile (const std::string& filename) { - FILE *file = fopen (filename.c_str(), "wb"); + FILE *file = nlfopen (filename, "wb"); if (file) { @@ -2311,13 +2311,13 @@ static bool CopyMoveFile(const std::string &dest, const std::string &src, bool c { totalSize = CFile::getFileSize(ssrc); } - FILE *fp1 = fopen(ssrc.c_str(), "rb"); + FILE *fp1 = nlfopen(ssrc, "rb"); if (fp1 == NULL) { nlwarning ("PATH: CopyMoveFile error: can't fopen in read mode '%s'", ssrc.c_str()); return false; } - FILE *fp2 = fopen(sdest.c_str(), "wb"); + FILE *fp2 = nlfopen(sdest, "wb"); if (fp2 == NULL) { nlwarning ("PATH: CopyMoveFile error: can't fopen in read write mode '%s'", sdest.c_str()); diff --git a/code/nel/src/misc/sha1.cpp b/code/nel/src/misc/sha1.cpp index 19e8a440a..8afa0c039 100644 --- a/code/nel/src/misc/sha1.cpp +++ b/code/nel/src/misc/sha1.cpp @@ -147,7 +147,7 @@ CHashKey getSHA1(const string &filename, bool forcePath) return CHashKey(); } - //FILE *fp = fopen (filename.c_str(), "rb"); + //FILE *fp = nlfopen (filename, "rb"); //if (fp == NULL) return CHashKey(); err = SHA1Reset(&sha); diff --git a/code/nel/src/misc/sstring.cpp b/code/nel/src/misc/sstring.cpp index 5f5702d01..a42981421 100644 --- a/code/nel/src/misc/sstring.cpp +++ b/code/nel/src/misc/sstring.cpp @@ -1743,7 +1743,7 @@ namespace NLMISC bool CSString::readFromFile(const CSString& fileName) { FILE* file; - file=fopen(fileName.c_str(),"rb"); + file = nlfopen(fileName, "rb"); if (file==NULL) { clear(); @@ -1766,7 +1766,7 @@ namespace NLMISC bool CSString::writeToFile(const CSString& fileName) const { FILE* file; - file=fopen(fileName.c_str(),"wb"); + file = nlfopen(fileName, "wb"); if (file==NULL) { nlwarning("Failed to open file for writing: %s",fileName.c_str()); diff --git a/code/nel/src/misc/xml_pack.cpp b/code/nel/src/misc/xml_pack.cpp index 4494be062..ec12eb6bc 100644 --- a/code/nel/src/misc/xml_pack.cpp +++ b/code/nel/src/misc/xml_pack.cpp @@ -93,7 +93,7 @@ namespace NLMISC TXMLPackInfo &packInfo = _XMLPacks[packId]; // open the xml pack for later access -// packInfo.FileHandler = fopen(xmlPackFileName.c_str(), "rb"); +// packInfo.FileHandler = nlfopen(xmlPackFileName, "rb"); // open the xml pack for parsing CIFile packFile; @@ -182,7 +182,7 @@ namespace NLMISC fileInfo.FileName = CStringMapper::map(subFileName); fileInfo.FileOffset = (uint32)(beginOfFile - buffer.begin()); fileInfo.FileSize = (uint32)(endOfFile - beginOfFile); -// fileInfo.FileHandler = fopen(xmlPackFileName.c_str(), "rb"); +// fileInfo.FileHandler = nlfopen(xmlPackFileName, "rb"); packInfo._XMLFiles.insert(make_pair(fileInfo.FileName, fileInfo)); // advance to next line @@ -264,7 +264,7 @@ namespace NLMISC rFileOffset = fileInfo.FileOffset; rCacheFileOnOpen = false; rAlwaysOpened = false; - FILE *fp = fopen(parts[0].c_str(), "rb"); + FILE *fp = nlfopen(parts[0], "rb"); return fp; } diff --git a/code/nel/src/net/email.cpp b/code/nel/src/net/email.cpp index ae6f92477..9ac22c886 100644 --- a/code/nel/src/net/email.cpp +++ b/code/nel/src/net/email.cpp @@ -271,7 +271,7 @@ bool sendEmail (const string &smtpServer, const string &from, const string &to, char dst_buf[dst_buf_size + 1]; size_t size; - FILE *src_stream = fopen (attachedFile.c_str(), "rb"); + FILE *src_stream = nlfopen (attachedFile, "rb"); if (src_stream == NULL) { nlwarning ("EMAIL: Can't attach file '%s' to the email because the file can't be open", attachedFile.c_str()); @@ -299,7 +299,7 @@ bool sendEmail (const string &smtpServer, const string &from, const string &to, } // debug, display what we send into a file - // { FILE *fp = fopen (CFile::findNewFile(getLogDirectory() + "mail.txt").c_str(), "wb"); + // { FILE *fp = nlfopen (CFile::findNewFile(getLogDirectory() + "mail.txt"), "wb"); // fwrite (formatedBody.c_str(), 1, formatedBody.size(), fp); // fclose (fp); } diff --git a/code/nel/src/net/service.cpp b/code/nel/src/net/service.cpp index 8f5a142cc..610fd1a1d 100644 --- a/code/nel/src/net/service.cpp +++ b/code/nel/src/net/service.cpp @@ -575,7 +575,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName, if (haveLongArg("writepid")) { // use legacy C primitives - FILE *fp = fopen("pid.state", "wt"); + FILE *fp = nlfopen("pid.state", "wt"); if (fp) { fprintf(fp, "%u", getpid()); @@ -623,7 +623,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName, else { // create the basic .cfg that link the default one - FILE *fp = fopen (cfn.c_str(), "w"); + FILE *fp = nlfopen (cfn, "w"); if (fp == NULL) { nlerror ("SERVICE: Can't create config file '%s'", cfn.c_str()); diff --git a/code/nel/tools/nel_unit_test/ut_ligo_primitive.h b/code/nel/tools/nel_unit_test/ut_ligo_primitive.h index 8df4db877..d4ba5df5a 100644 --- a/code/nel/tools/nel_unit_test/ut_ligo_primitive.h +++ b/code/nel/tools/nel_unit_test/ut_ligo_primitive.h @@ -72,7 +72,7 @@ private: + " \n" + ""; - FILE *fp = fopen(CLASS_FILE_NAME, "wt"); + FILE *fp = NLMISC::nlfopen(CLASS_FILE_NAME, "wt"); nlassert(fp != NULL); size_t s = fwrite(classfile.data(), 1, classfile.size(), fp); nlassert(s == classfile.size()); diff --git a/code/nel/tools/nel_unit_test/ut_misc_file.h b/code/nel/tools/nel_unit_test/ut_misc_file.h index 34de2d569..486320269 100644 --- a/code/nel/tools/nel_unit_test/ut_misc_file.h +++ b/code/nel/tools/nel_unit_test/ut_misc_file.h @@ -19,6 +19,7 @@ #include #include +#include // Test suite for NLMISC::CFile behavior struct CUTMiscFile : public Test::Suite @@ -49,7 +50,7 @@ private: void copyFileSize(uint fileSize) { // create a source file (using standard c code) - FILE *fp = fopen(_SrcFile.c_str(), "wb"); + FILE *fp = NLMISC::nlfopen(_SrcFile, "wb"); nlverify(fp != NULL); for (uint i=0; iwrite(id,f); - fclose(f); + FILE * f = nlfopen(fileName, "w"); + if (f) + { + ICDBNode::CTextId id; + _Database->write(id,f); + fclose(f); + + res = true; + } } - else + + if (!res) { nlwarning(" can't write %s : the database has not been initialized",fileName.c_str()); } diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 8696b3a35..84ccada65 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -1931,7 +1931,7 @@ void CClientConfig::init(const string &configFileName) if(!CFile::fileExists(configFileName)) { // create the basic .cfg - FILE *fp = fopen(configFileName.c_str(), "w"); + FILE *fp = nlfopen(configFileName, "w"); if (fp == NULL) nlerror("CFG::init: Can't create config file '%s'", configFileName.c_str()); diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index f958869f5..3308ee7ad 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -695,7 +695,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", " if (ClientCfg.Local) sys += "ShardName OFFLINE "; - FILE *fp = fopen (std::string(getLogDirectory() + "bug_report.txt").c_str(), "wb"); + FILE *fp = nlfopen (getLogDirectory() + "bug_report.txt", "wb"); if (fp != NULL) { string res = addSlashR(getDebugInformation()); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b8721ffdd..4d2248249 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2704,7 +2704,7 @@ void CInterfaceManager::log(const ucstring &str, const std::string &cat) { // Open file with the name of the player const string fileName= "save/log_" + PlayerSelectedFileName + ".txt"; - FILE *f = fopen(fileName.c_str(), "at"); + FILE *f = nlfopen(fileName, "at"); if (f != NULL) { const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8(); diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 0c4abc207..d50ace059 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -869,7 +869,7 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool std::string batchFilename = ClientRootPath + UpdateBatchFilename; - FILE *fp = fopen (batchFilename.c_str(), "wt"); + FILE *fp = nlfopen (batchFilename, "wt"); if (fp == NULL) { @@ -1302,7 +1302,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de setRWAccess(dest, false); NLMISC::CFile::deleteFile(dest.c_str()); } - FILE *fp = fopen (dest.c_str(), "wb"); + FILE *fp = nlfopen (dest, "wb"); if (fp == NULL) { curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL); @@ -1441,8 +1441,8 @@ void CPatchManager::decompressFile (const string &filename) string dest = filename.substr(0, filename.size ()-4); setRWAccess(dest, false); - //if(isVerboseLog()) nlinfo("Calling fopen('%s','wb')", dest.c_str()); - FILE *fp = fopen (dest.c_str(), "wb"); + //if(isVerboseLog()) nlinfo("Calling nlfopen('%s','wb')", dest.c_str()); + FILE *fp = nlfopen (dest, "wb"); if (fp == NULL) { string err = toString("Can't open file '%s' : code=%d %s, (error code 32)", dest.c_str(), errno, strerror(errno)); @@ -2192,7 +2192,7 @@ void CCheckThread::run () if (bnpFile.readHeader()) { // read the file inside the bnp and calculate the sha1 - FILE *bnp = fopen (sBNPFilename.c_str(), "rb"); + FILE *bnp = nlfopen (sBNPFilename, "rb"); if (bnp != NULL) { for (uint32 k = 0; k < bnpFile.SFiles.size(); ++k) @@ -3068,7 +3068,7 @@ bool CPatchManager::extract(const std::string& patchPath, uint nblab = 0; pPM->deleteFile(updateBatchFilename, false, false); - FILE *fp = fopen (updateBatchFilename.c_str(), "wt"); + FILE *fp = nlfopen (updateBatchFilename, "wt"); if (fp == 0) { diff --git a/code/ryzom/client/src/login_xdelta.cpp b/code/ryzom/client/src/login_xdelta.cpp index f8e733b68..d2daf0827 100644 --- a/code/ryzom/client/src/login_xdelta.cpp +++ b/code/ryzom/client/src/login_xdelta.cpp @@ -143,7 +143,7 @@ bool CXDPFileReader::init(const std::string &sFilename, sint32 nLowerBound, sint } else { - _File = fopen(sFilename.c_str(), "rb"); + _File = nlfopen(sFilename, "rb"); if (_File == NULL) return false; fseek(_File, nLowerBound, SEEK_SET); @@ -560,7 +560,7 @@ CXDeltaPatch::TApplyResult CXDeltaPatch::apply(const std::string &sFileToPatch, errorMsg = toString("output file %s already exists", sFileOutput.c_str()); return ApplyResult_Error; } - FILE *outFILE = fopen(sFileOutput.c_str(), "wb"); + FILE *outFILE = nlfopen(sFileOutput, "wb"); if (outFILE == NULL) { errorMsg = toString("cant create %s", sFileOutput.c_str()); @@ -572,7 +572,7 @@ CXDeltaPatch::TApplyResult CXDeltaPatch::apply(const std::string &sFileToPatch, bool ftpPresent = false; if (pFromSource) { - ftpFILE = fopen(sFileToPatch.c_str(), "rb"); + ftpFILE = nlfopen(sFileToPatch, "rb"); if (ftpFILE == NULL) { errorMsg = toString("expecting file %s", sFileToPatch.c_str()); diff --git a/code/ryzom/client/src/permanent_ban.cpp b/code/ryzom/client/src/permanent_ban.cpp index fe56446d2..cf604db2b 100644 --- a/code/ryzom/client/src/permanent_ban.cpp +++ b/code/ryzom/client/src/permanent_ban.cpp @@ -141,7 +141,7 @@ static void markBNPFile(std::string &path) uint32 nFileSize=CFile::getFileSize(path); if (!nFileSize) return; - FILE *f = fopen(path.c_str(), "rb+"); + FILE *f = nlfopen(path, "rb+"); if (!f) return; // Result if (nlfseek64 (f, nFileSize-4, SEEK_SET) != 0) diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index 073be77cc..d47093c5d 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -1384,7 +1384,7 @@ bool CClientEditionModule::loadUserComponent(const std::string& filename, bool m uint32 timeStamp = 0; if (! compressed) { - FILE* file = fopen(filename.c_str(),"rb"); + FILE* file = nlfopen(filename, "rb"); if (!file) { nlwarning("Try to open an invalid file %s (access error)", filename.c_str()); @@ -1491,7 +1491,7 @@ bool CClientEditionModule::loadUserComponent(const std::string& filename, bool m else { // Get Uncompressed File length (4 last byte of a gz) - FILE* file = fopen(filename.c_str(),"rb"); + FILE* file = nlfopen(filename, "rb"); if (!file) { nlwarning("Try to open an invalid file %s (access error)", filename.c_str()); @@ -1653,7 +1653,7 @@ void CClientEditionModule::saveUserComponentFile(const std::string& filename, bo if (!mustCompress) { { - FILE* output = fopen(uncompressedName.c_str(), "wb"); + FILE* output = nlfopen(uncompressedName, "wb"); if (output) { fwrite(component->UncompressedData, sizeof(char) , component->UncompressedDataLength, output); diff --git a/code/ryzom/client/src/seven_zip/seven_zip.cpp b/code/ryzom/client/src/seven_zip/seven_zip.cpp index 28ae2d0f7..765500deb 100644 --- a/code/ryzom/client/src/seven_zip/seven_zip.cpp +++ b/code/ryzom/client/src/seven_zip/seven_zip.cpp @@ -154,7 +154,7 @@ bool unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName SzArEx_GetFileNameUtf16(&db, 0, &filename[0]); // write the extracted file - FILE *outputHandle = fopen(destFileName.c_str(), "wb+"); + FILE *outputHandle = nlfopen(destFileName, "wb+"); if (outputHandle == 0) { diff --git a/code/ryzom/client/src/sheet_manager.cpp b/code/ryzom/client/src/sheet_manager.cpp index cdb9b4ff1..3c902ed74 100644 --- a/code/ryzom/client/src/sheet_manager.cpp +++ b/code/ryzom/client/src/sheet_manager.cpp @@ -1020,7 +1020,7 @@ void CSheetManager::dumpVisualSlots() // *************************************************************************** void CSheetManager::dumpVisualSlotsIndex() { - FILE * vsIndexFile = fopen(std::string(getLogDirectory() + "vs_index.txt").c_str(),"w"); + FILE * vsIndexFile = nlfopen(getLogDirectory() + "vs_index.txt", "w"); if( vsIndexFile ) { for (uint i=0; i < SLOTTYPE::NB_SLOT; ++i) diff --git a/code/ryzom/common/src/game_share/bmp4image.h b/code/ryzom/common/src/game_share/bmp4image.h index 542fc4200..4ecbd79f5 100644 --- a/code/ryzom/common/src/game_share/bmp4image.h +++ b/code/ryzom/common/src/game_share/bmp4image.h @@ -65,7 +65,7 @@ public: /*bool write(char *filename) { - FILE *outf=fopen(filename,"wb"); + FILE *outf=nlfopen(filename, "wb"); if (outf==NULL) return false; diff --git a/code/ryzom/common/src/game_share/persistent_data.cpp b/code/ryzom/common/src/game_share/persistent_data.cpp index 85c873ba4..a9fe8b344 100644 --- a/code/ryzom/common/src/game_share/persistent_data.cpp +++ b/code/ryzom/common/src/game_share/persistent_data.cpp @@ -1120,7 +1120,7 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName) #ifdef NL_OS_WINDOWS // open the file - FILE* inf= fopen(fileName.c_str(), "rb"); + FILE* inf= nlfopen(fileName, "rb"); DROP_IF( inf==NULL, "Failed to open input file " << fileName, return false); // get the file size