Use new wrapper insteaf of fopen, issue #261

--HG--
branch : develop
feature/pipeline-tools
kervala 9 years ago
parent e69090c457
commit aaecf96b67

@ -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");

@ -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;

@ -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);

@ -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;

@ -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));

@ -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 ());

@ -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;

@ -93,7 +93,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
return true;
}
*/
/* FILE *fp = fopen(filename.c_str(), "rb");
/* FILE *fp = nlfopen(filename, "rb");
if (fp == NULL)
{

@ -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));
}

@ -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());

@ -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;
}

@ -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());

@ -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);

@ -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());

@ -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;
}

@ -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); }

@ -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());

@ -72,7 +72,7 @@ private:
+ " </PRIMITIVE>\n"
+ "</NEL_LIGO_PRIMITIVE_CLASS>";
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());

@ -19,6 +19,7 @@
#include <nel/misc/file.h>
#include <nel/misc/path.h>
#include <nel/misc/common.h>
// 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; i<fileSize; ++i)
@ -63,7 +64,7 @@ private:
NLMISC::CFile::copyFile(_DstFile, _SrcFile, false);
// verify the resulting file
fp = fopen(_DstFile.c_str(), "rb");
fp = NLMISC::nlfopen(_DstFile, "rb");
TEST_ASSERT(fp != NULL);
if (fp)
{
@ -108,7 +109,7 @@ private:
void moveFileSize(size_t fileSize)
{
// remove the destination if any
FILE *fp = fopen(_DstFile.c_str(), "rb");
FILE *fp = NLMISC::nlfopen(_DstFile, "rb");
if (fp != NULL)
{
fclose(fp);
@ -116,7 +117,7 @@ private:
}
// create a source file (using standard c code)
fp = fopen(_SrcFile.c_str(), "wb");
fp = NLMISC::nlfopen(_SrcFile, "wb");
nlverify(fp != NULL);
for (uint i=0; i<fileSize; ++i)
@ -130,12 +131,12 @@ private:
NLMISC::CFile::moveFile(_DstFile, _SrcFile);
// verify the resulting file
fp = fopen(_SrcFile.c_str(), "rb");
fp = NLMISC::nlfopen(_SrcFile, "rb");
TEST_ASSERT_MSG(fp == NULL, "The source file is not removed");
if (fp)
fclose(fp);
fp = fopen(_DstFile.c_str(), "rb");
fp = NLMISC::nlfopen(_DstFile, "rb");
TEST_ASSERT(fp != NULL);
if (fp)
{

@ -156,15 +156,22 @@ void CCDBSynchronised::read( const string &fileName )
//-----------------------------------------------
void CCDBSynchronised::write( const string &fileName )
{
bool res = false;
if( _Database != 0 )
{
FILE * f;
f = fopen(fileName.c_str(),"w");
ICDBNode::CTextId id;
_Database->write(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("<CCDBSynchronised::write> can't write %s : the database has not been initialized",fileName.c_str());
}

@ -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());

@ -695,7 +695,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", "<AddScreenshot>
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());

@ -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();

@ -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)
{

@ -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());

@ -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)

@ -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);

@ -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)
{

@ -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)

@ -65,7 +65,7 @@ public:
/*bool write(char *filename)
{
FILE *outf=fopen(filename,"wb");
FILE *outf=nlfopen(filename, "wb");
if (outf==NULL)
return false;

@ -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

Loading…
Cancel
Save