Fixed: Display an error if adding more than once the same filename in BNP

This commit is contained in:
kervala 2016-01-23 18:49:10 +01:00
parent d06bff716f
commit be0355c570

View file

@ -92,22 +92,32 @@ void packSubRecurse(const std::string &srcDirectory)
printf ("Treating directory: %s\n", srcDirectory.c_str());
CPath::getPathContent(srcDirectory, true, false, true, pathContent);
// TODO: remove duplicate files
if (pathContent.empty()) return;
// Sort filename
sort (pathContent.begin(), pathContent.end(), i_comp);
// check for files with same name
for(uint i = 1, len = pathContent.size(); i < len; ++i)
{
if (toLower(CFile::getFilename(pathContent[i-1])) == toLower(CFile::getFilename(pathContent[i])))
{
nlerror("File %s is not unique in BNP!", CFile::getFilename(pathContent[i]).c_str());
return;
}
}
for (uint i=0; i<pathContent.size(); ++i)
{
if (keepFile(pathContent[i]))
{
if (gBNPHeader.appendFile(pathContent[i]))
{
printf("adding %s\n", pathContent[i].c_str());
printf("Adding %s\n", pathContent[i].c_str());
}
else
{
printf("error cannot open %s\n", pathContent[i].c_str());
printf("Error: cannot open %s\n", pathContent[i].c_str());
}
}
}