Merge remote branch 'werdanith/searchfix'

actorid
Marc Zinnschlag 13 years ago
commit a7211d2a90

@ -136,7 +136,7 @@ namespace MWSound
max = std::max(min, max);
}
return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict, true);
return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict, false);
}
// Add a sound to the list and play it

@ -13,6 +13,14 @@ bool isFile(const char *name)
return boost::filesystem::exists(boost::filesystem::path(name));
}
// Returns true if the last part of the superset matches the subset
bool endingMatches(const std::string& superset, const std::string& subset)
{
if (subset.length() > superset.length())
return false;
return superset.substr(superset.length() - subset.length()) == subset;
}
// Makes a list of files from a directory
void FileLister( boost::filesystem::path currentPath, Files::PathContainer& list, bool recursive)
{
@ -85,11 +93,14 @@ bool isFile(const char *name)
for (Files::PathContainer::const_iterator it = list.begin(); it != list.end(); ++it)
{
fullPath = it->string();
if (ignoreExtensions)
fullPath.erase(fullPath.length() - it->extension().string().length());
if (!strict)
{
boost::algorithm::to_lower(fullPath);
}
if(fullPath.find(toFindStr) != std::string::npos)
if(endingMatches(fullPath, toFindStr))
{
result = *it;
break;

Loading…
Cancel
Save