Fix matching "x*.*" in wxMSW wxDir too

Recent commit corrected handling of "*.*", which previously didn't match
the files without extensions, but still left handling of patterns such
as "x*.*" broken, because they are also supposed to match all files
starting with "x" under Windows, whether they have an extension or not.

Fix this by using PathMatchSpecEx() shell function which should handle
this correctly and update the unit test to check for this case as well.
This commit is contained in:
Vadim Zeitlin 2023-09-29 16:36:47 +02:00
parent f27688367a
commit 22c629d667
2 changed files with 10 additions and 18 deletions

View file

@ -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 );