summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-05-19 18:43:19 +0200
committerMax Kellermann <max@musicpd.org>2021-05-19 18:43:19 +0200
commit96707c04266ffba8e8faad9f90ad34dd09d14b3e (patch)
tree997afd845f1dfc54e25a9c55be0a45dcdff1ac07 /src/fs
parente016cc894090127c5fe72b009290b4bf4a534363 (diff)
parent3547fc7e61a1339680fca81efda562a28c68c373 (diff)
Merge tag 'v0.22.7'
release v0.22.7
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/DirectoryReader.hxx2
-rw-r--r--src/fs/Glob.cxx36
-rw-r--r--src/fs/Glob.hxx31
-rw-r--r--src/fs/StandardDirectory.cxx4
-rw-r--r--src/fs/io/FileOutputStream.hxx5
-rw-r--r--src/fs/io/FileReader.hxx5
-rw-r--r--src/fs/meson.build1
7 files changed, 65 insertions, 19 deletions
diff --git a/src/fs/DirectoryReader.hxx b/src/fs/DirectoryReader.hxx
index abf63957e..3ee1fd876 100644
--- a/src/fs/DirectoryReader.hxx
+++ b/src/fs/DirectoryReader.hxx
@@ -24,7 +24,7 @@
#ifdef _WIN32
-#include <windows.h>
+#include <fileapi.h>
#include <tchar.h>
/**
diff --git a/src/fs/Glob.cxx b/src/fs/Glob.cxx
new file mode 100644
index 000000000..f2119bd9a
--- /dev/null
+++ b/src/fs/Glob.cxx
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#ifdef _WIN32
+// COM needs the "MSG" typedef, and shlwapi.h includes COM headers
+#undef NOUSER
+#endif
+
+#include "Glob.hxx"
+
+#ifdef _WIN32
+#include <shlwapi.h>
+
+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 0a2e9abfc..65e3a9e1f 100644
--- a/src/fs/Glob.hxx
+++ b/src/fs/Glob.hxx
@@ -24,45 +24,44 @@
#ifdef HAVE_FNMATCH
#define HAVE_CLASS_GLOB
-#include <string>
#include <fnmatch.h>
#elif defined(_WIN32)
#define HAVE_CLASS_GLOB
-#include <string>
-#include <shlwapi.h>
#endif
#ifdef HAVE_CLASS_GLOB
#include "util/Compiler.h"
+#include <string>
+
/**
* A pattern that matches file names. It may contain shell wildcards
* (asterisk and question mark).
*/
class Glob {
-#if defined(HAVE_FNMATCH) || defined(_WIN32)
std::string pattern;
-#endif
public:
-#if defined(HAVE_FNMATCH) || defined(_WIN32)
explicit Glob(const char *_pattern)
:pattern(_pattern) {}
- Glob(Glob &&other)
- :pattern(std::move(other.pattern)) {}
-#endif
+ Glob(Glob &&other) noexcept = default;
+ 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;
};
+#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/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx
index 05bee122b..7190f7a95 100644
--- a/src/fs/StandardDirectory.cxx
+++ b/src/fs/StandardDirectory.cxx
@@ -17,6 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifdef _WIN32
+#undef NOUSER // COM needs the "MSG" typedef, and shlobj.h includes COM headers
+#endif
+
#include "StandardDirectory.hxx"
#include "FileSystem.hxx"
#include "XDG.hxx"
diff --git a/src/fs/io/FileOutputStream.hxx b/src/fs/io/FileOutputStream.hxx
index d377f08ea..10c614831 100644
--- a/src/fs/io/FileOutputStream.hxx
+++ b/src/fs/io/FileOutputStream.hxx
@@ -42,7 +42,10 @@
#include <cstdint>
#ifdef _WIN32
-#include <windows.h>
+#include <fileapi.h>
+#include <windef.h> // for HWND (needed by winbase.h)
+#include <handleapi.h> // for INVALID_HANDLE_VALUE
+#include <winbase.h> // for FILE_END
#endif
#if defined(__linux__) && !defined(ANDROID)
diff --git a/src/fs/io/FileReader.hxx b/src/fs/io/FileReader.hxx
index bee39cc9a..5be332b72 100644
--- a/src/fs/io/FileReader.hxx
+++ b/src/fs/io/FileReader.hxx
@@ -35,7 +35,10 @@
#include "util/Compiler.h"
#ifdef _WIN32
-#include <windows.h>
+#include <fileapi.h>
+#include <handleapi.h> // for INVALID_HANDLE_VALUE
+#include <windef.h> // for HWND (needed by winbase.h)
+#include <winbase.h> // for FILE_CURRENT
#else
#include "io/UniqueFileDescriptor.hxx"
#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',