diff options
author | Aki <please@ignore.pl> | 2022-09-11 18:16:34 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-09-11 18:16:34 +0200 |
commit | d9486493ded25426042a5f6327c097a6cad756b4 (patch) | |
tree | 9e8258d6ef68f36f10f485b518efc1f66be70bd1 | |
parent | 687b6012122ded0a1dd4c1df8f8795d8855506a3 (diff) | |
download | starshatter-d9486493ded25426042a5f6327c097a6cad756b4.zip starshatter-d9486493ded25426042a5f6327c097a6cad756b4.tar.gz starshatter-d9486493ded25426042a5f6327c097a6cad756b4.tar.bz2 |
Fixed WIN32 build of dat
There might be small differences between option handling and fnmatch vs. PathMatchSpecA,
but that's understandable.
-rw-r--r-- | ArchiveEx/CMakeLists.txt | 6 | ||||
-rw-r--r-- | ArchiveEx/dat.cpp | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/ArchiveEx/CMakeLists.txt b/ArchiveEx/CMakeLists.txt index 62e414e..158e2b3 100644 --- a/ArchiveEx/CMakeLists.txt +++ b/ArchiveEx/CMakeLists.txt @@ -19,3 +19,9 @@ target_link_libraries( dat PRIVATE ArchiveEx ) +if(WIN32) + target_link_libraries( + dat + PRIVATE -l:libshlwapi.a + ) +endif() diff --git a/ArchiveEx/dat.cpp b/ArchiveEx/dat.cpp index 9662cbc..6df04bc 100644 --- a/ArchiveEx/dat.cpp +++ b/ArchiveEx/dat.cpp @@ -1,4 +1,9 @@ +#ifdef WIN32 +#include <shlwapi.h> +#else #include <fnmatch.h> +#endif + #include <unistd.h> #include <cstdint> @@ -174,8 +179,11 @@ FilterFile(const std::vector<std::string>& patterns, std::function<void(const ch if (patterns.empty()) return func(name); for (const auto& pattern : patterns) { - const int match = fnmatch(pattern.c_str(), name, FNM_PATHNAME | FNM_LEADING_DIR); - if (match == 0) +#ifdef WIN32 + if (PathMatchSpecA(name, pattern.c_str())) +#else + if (0 == fnmatch(pattern.c_str(), name, FNM_PATHNAME | FNM_LEADING_DIR)) +#endif return func(name); } }; @@ -192,7 +200,7 @@ UpdateFile(ArchiveEx::Archive& archive, const std::string& path, bool warn) break; case fs::file_type::directory: for (const auto& entry : fs::directory_iterator{path}) - UpdateFile(archive, entry.path(), false); + UpdateFile(archive, entry.path().string(), false); break; default: if (warn) |