#include <sstream>
#include <stdexcept>
+#include <algorithm>
#include <cstdlib>
#include <list>
#include <physfs.h>
// get filename of potential archive
std::string fileName = *i;
- static const std::string archiveDir = PHYSFS_getRealDir(fileName.c_str());
+ const std::string archiveDir = PHYSFS_getRealDir(fileName.c_str());
static const std::string dirSep = PHYSFS_getDirSeparator();
std::string fullFilename = archiveDir + dirSep + fileName;
// make sure it looks like an infoFile
static const std::string infoExt = ".nfo";
- if (potentialInfoFileName.compare(potentialInfoFileName.length()-infoExt.length(), infoExt.length(), infoExt) != 0) continue;
+ if (potentialInfoFileName.length() <= infoExt.length())
+ continue;
+
+ if (potentialInfoFileName.compare(potentialInfoFileName.length()-infoExt.length(), infoExt.length(), infoExt) != 0)
+ continue;
// make sure it's in the current archive
std::string infoFileDir = PHYSFS_getRealDir(potentialInfoFileName.c_str());