diff options
| author | degasus <wickmarkus@web.de> | 2013-01-24 16:58:28 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2013-01-24 16:58:28 +0100 |
| commit | e0ffdda26e5fb34b2f0d59d5d45b0deda9c90c19 (patch) | |
| tree | 8e289ea93c97fe7430ae501200b60327f572c7e2 /Source/Core/Common/Src/FileSearch.cpp | |
| parent | d5748ebaef93cd601ae6ab5e12f39dd201593ad0 (diff) | |
| parent | d60cc373d1b389215eb63c4e20fe24e902680c7a (diff) | |
Merge branch 'immediate-removal' into GLSL-master
Conflicts:
Source/Core/VideoCommon/Src/PixelShaderGen.cpp
Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
immediate-removal is a new created branch seperated from master but reverted the revert of immediate-removal
so we get less conflicts by merging
Diffstat (limited to 'Source/Core/Common/Src/FileSearch.cpp')
| -rw-r--r-- | Source/Core/Common/Src/FileSearch.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/Source/Core/Common/Src/FileSearch.cpp b/Source/Core/Common/Src/FileSearch.cpp index c60ce9beda..595dfe7000 100644 --- a/Source/Core/Common/Src/FileSearch.cpp +++ b/Source/Core/Common/Src/FileSearch.cpp @@ -25,6 +25,7 @@ #endif #include <string> +#include <algorithm> #include "FileSearch.h" @@ -72,36 +73,36 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& #else - size_t dot_pos = _searchString.rfind("."); + // TODO: super lame/broken - if (dot_pos == std::string::npos) - return; + auto end_match(_searchString); + + // assuming we have a "*.blah"-like pattern + if (!end_match.empty() && end_match[0] == '*') + end_match.erase(0, 1); + + // ugly + if (end_match == ".*") + end_match.clear(); - std::string ext = _searchString.substr(dot_pos); DIR* dir = opendir(_strPath.c_str()); if (!dir) return; - dirent* dp; - - while (true) + while (auto const dp = readdir(dir)) { - dp = readdir(dir); - - if (!dp) - break; - - std::string s(dp->d_name); + std::string found(dp->d_name); - if ( (!ext.compare(".*") && s.compare(".") && s.compare("..")) || - ((s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) )) + if ((found != ".") && (found != "..") + && (found.size() >= end_match.size()) + && std::equal(end_match.rbegin(), end_match.rend(), found.rbegin())) { std::string full_name; if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR) - full_name = _strPath + s; + full_name = _strPath + found; else - full_name = _strPath + DIR_SEP + s; + full_name = _strPath + DIR_SEP + found; m_FileNames.push_back(full_name); } |
