Changed: Added getBigFileName method to CBigFile

This commit is contained in:
kervala 2010-10-18 09:12:49 +02:00
parent 89c384efcc
commit 85f757d902
2 changed files with 20 additions and 4 deletions

View file

@ -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<std::string> &vAllFiles);

View file

@ -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<string, BNP>::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<std::string> &vAllFiles)
{
@ -403,10 +415,11 @@ 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)
return NULL;
}
}
rCacheFileOnOpen = bnp->CacheFileOnOpen;
rAlwaysOpened = bnp->AlwaysOpened;