From 2aa54c53653abda99c72bfb007c3442a1c3c6d60 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 22 Jun 2015 21:18:40 +0200 Subject: [PATCH] fs/Glob: use PathMatchSpec() on Windows --- Makefile.am | 5 +++++ src/fs/Glob.hxx | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b230e2b66..1422c97f2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -578,6 +578,11 @@ libfs_a_SOURCES += \ FS_LIBS += $(ZLIB_LIBS) endif +if HAVE_WINDOWS +# for PathMatchSpec() +FS_LIBS += -lshlwapi +endif + # Storage library SMBCLIENT_SOURCES = \ diff --git a/src/fs/Glob.hxx b/src/fs/Glob.hxx index b7307feea..e0909bd38 100644 --- a/src/fs/Glob.hxx +++ b/src/fs/Glob.hxx @@ -26,6 +26,10 @@ #define HAVE_CLASS_GLOB #include #include +#elif defined(WIN32) +#define HAVE_CLASS_GLOB +#include +#include #elif defined(HAVE_GLIB) #define HAVE_CLASS_GLOB #include @@ -39,14 +43,14 @@ * (asterisk and question mark). */ class Glob { -#ifdef HAVE_FNMATCH +#if defined(HAVE_FNMATCH) || defined(WIN32) std::string pattern; #else GPatternSpec *pattern; #endif public: -#ifdef HAVE_FNMATCH +#if defined(HAVE_FNMATCH) || defined(WIN32) explicit Glob(const char *_pattern) :pattern(_pattern) {} @@ -70,6 +74,8 @@ public: bool Check(const char *name_fs) const { #ifdef HAVE_FNMATCH return fnmatch(pattern.c_str(), name_fs, 0) == 0; +#elif defined(WIN32) + return PathMatchSpecA(name_fs, pattern.c_str()); #else return g_pattern_match_string(pattern, name_fs); #endif