diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index 7d175d3467..7254b6553c 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -28,6 +28,11 @@ #include "wx/dir.h" #include "wx/msw/private.h" +#include + +#ifdef __VISUALC__ + #pragma comment(lib, "shlwapi") +#endif // ---------------------------------------------------------------------------- // define the types and functions used for file searching @@ -71,23 +76,7 @@ CheckFoundMatch(const FIND_STRUCT* finddata, const wxString& filter) if ( filter.empty() ) return true; - // Otherwise do check the match validity. Notice that we must do it - // case-insensitively because the case of the file names is not supposed to - // matter under Windows. - wxString fn(finddata.cFileName); - - // However if the filter contains only special characters (which is a - // common case), we can skip the case conversion. - if ( filter.find_first_not_of(wxS("*?.")) == wxString::npos ) - { - // And maybe even skip the check entirely if we have a filter that we - // know matches everything. This is more than just an optimization, as - // "*.*" it wouldn't match the files without extension according to - // wxString::Matches(), but it should. - return filter == wxS("*.*") || filter == wxS("*") || fn.Matches(filter); - } - - return fn.MakeUpper().Matches(filter.Upper()); + return ::PathMatchSpecEx(finddata->cFileName, filter, PMSF_NORMAL) == S_OK; } inline bool diff --git a/tests/file/dir.cpp b/tests/file/dir.cpp index 5d11f80a52..b15fed7f89 100644 --- a/tests/file/dir.cpp +++ b/tests/file/dir.cpp @@ -22,7 +22,7 @@ // We can't use wxFileSelectorDefaultWildcardStr from wxCore here, so define // our own. -const char WILDCARD_ALL[] = +const wxString WILDCARD_ALL = #if defined(__WXMSW__) "*.*" #else // Unix/Mac @@ -158,6 +158,9 @@ TEST_CASE_METHOD(DirTestCase, "Dir::Traverse", "[dir]") // enum all files using an explicit wildcard CHECK(wxDir::GetAllFiles(DIRTEST_FOLDER, &files, WILDCARD_ALL) == 4); + // enum all files using an explicit wildcard different from WILDCARD_ALL + CHECK(wxDir::GetAllFiles(DIRTEST_FOLDER, &files, "d" + WILDCARD_ALL) == 4); + // enum all files according to the filter CHECK( wxDir::GetAllFiles(DIRTEST_FOLDER, &files, "*.foo") == 1 );