From 85f757d902ed26edb6a7d9184acb7a28c4def634 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:12:49 +0200 Subject: [PATCH] Changed: Added getBigFileName method to CBigFile --- code/nel/include/nel/misc/big_file.h | 5 ++++- code/nel/src/misc/big_file.cpp | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/misc/big_file.h b/code/nel/include/nel/misc/big_file.h index 582b44e46..c7c96912a 100644 --- a/code/nel/include/nel/misc/big_file.h +++ b/code/nel/include/nel/misc/big_file.h @@ -58,7 +58,10 @@ public: void remove (const std::string &sBigFileName); // true if a bigFile is added - bool isBigFileAdded(const std::string &sBigFileName); + bool isBigFileAdded(const std::string &sBigFileName) const; + + // return name of Big File + std::string getBigFileName(const std::string &sBigFileName) const; // List all files in a bigfile void list (const std::string &sBigFileName, std::vector &vAllFiles); diff --git a/code/nel/src/misc/big_file.cpp b/code/nel/src/misc/big_file.cpp index 1521efb5f..e60f8d8a2 100644 --- a/code/nel/src/misc/big_file.cpp +++ b/code/nel/src/misc/big_file.cpp @@ -295,13 +295,25 @@ void CBigFile::remove (const std::string &sBigFileName) } // *************************************************************************** -bool CBigFile::isBigFileAdded(const std::string &sBigFileName) +bool CBigFile::isBigFileAdded(const std::string &sBigFileName) const { // Is already the same bigfile name ? string bigfilenamealone = CFile::getFilename (sBigFileName); return _BNPs.find(bigfilenamealone) != _BNPs.end(); } +// *************************************************************************** +std::string CBigFile::getBigFileName(const std::string &sBigFileName) const +{ + string bigfilenamealone = CFile::getFilename (sBigFileName); + map::const_iterator it = _BNPs.find(bigfilenamealone); + if (it != _BNPs.end()) + return it->second.BigFileName; + else + return ""; +} + + // *************************************************************************** void CBigFile::list (const std::string &sBigFileName, std::vector &vAllFiles) { @@ -403,9 +415,10 @@ FILE* CBigFile::getFile (const std::string &sFileName, uint32 &rFileSize, { handle.File = fopen (bnp->BigFileName.c_str(), "rb"); if (handle.File == NULL) - nlwarning ("bnp: can't fopen big file '%s' error %d '%s'", bnp->BigFileName.c_str(), errno, strerror(errno)); - if (handle.File == NULL) + { + nlwarning ("bnp: can't fopen big file '%s' error %d '%s'", bnp->BigFileName.c_str(), errno, strerror(errno)); return NULL; + } } rCacheFileOnOpen = bnp->CacheFileOnOpen;