From c64a3b5dbb25fceabfa30828462bf8a855141e21 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 19 May 2021 17:39:03 +0200 Subject: [PATCH] fs/Glob: un-inline the Windows version to reduce header dependencies --- src/fs/Glob.cxx | 31 +++++++++++++++++++++++++++++++ src/fs/Glob.hxx | 21 ++++++++++++--------- src/fs/meson.build | 1 + 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 src/fs/Glob.cxx diff --git a/src/fs/Glob.cxx b/src/fs/Glob.cxx new file mode 100644 index 000000000..4467853d0 --- /dev/null +++ b/src/fs/Glob.cxx @@ -0,0 +1,31 @@ +/* + * Copyright 2003-2021 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "Glob.hxx" + +#ifdef _WIN32 +#include + +bool +Glob::Check(const char *name_fs) const noexcept +{ + return PathMatchSpecA(name_fs, pattern.c_str()); +} + +#endif diff --git a/src/fs/Glob.hxx b/src/fs/Glob.hxx index 7c33af782..65e3a9e1f 100644 --- a/src/fs/Glob.hxx +++ b/src/fs/Glob.hxx @@ -27,7 +27,6 @@ #include #elif defined(_WIN32) #define HAVE_CLASS_GLOB -#include #endif #ifdef HAVE_CLASS_GLOB @@ -50,15 +49,19 @@ public: Glob &operator=(Glob &&other) noexcept = default; gcc_pure - bool Check(const char *name_fs) const noexcept { -#ifdef HAVE_FNMATCH - return fnmatch(pattern.c_str(), name_fs, 0) == 0; -#elif defined(_WIN32) - return PathMatchSpecA(name_fs, pattern.c_str()); -#endif - } + bool Check(const char *name_fs) const noexcept; }; -#endif +#ifdef HAVE_FNMATCH + +inline bool +Glob::Check(const char *name_fs) const noexcept +{ + return fnmatch(pattern.c_str(), name_fs, 0) == 0; +} + +#endif + +#endif /* HAVE_CLASS_GLOB */ #endif diff --git a/src/fs/meson.build b/src/fs/meson.build index 483df7694..2e483e7ae 100644 --- a/src/fs/meson.build +++ b/src/fs/meson.build @@ -3,6 +3,7 @@ fs_sources = [ 'Traits.cxx', 'Config.cxx', 'Charset.cxx', + 'Glob.cxx', 'Path.cxx', 'Path2.cxx', 'AllocatedPath.cxx',