From f1f6051cf79aa8dc1d69b94c96a4286ba8a16849 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sat, 7 Jan 2023 11:07:00 +0000 Subject: [PATCH] Fixed path filters on Windows --- src/common/model/diagram_filter.cc | 4 +++- src/common/model/source_file.h | 6 +++++- src/config/config.cc | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/model/diagram_filter.cc b/src/common/model/diagram_filter.cc index b65e12b4..bac06e6b 100644 --- a/src/common/model/diagram_filter.cc +++ b/src/common/model/diagram_filter.cc @@ -391,8 +391,10 @@ tvl::value_t paths_filter::match( auto pp = p.fs_path(root_); for (const auto &path : paths_) { - if (util::starts_with(pp, path)) + if (pp.root_name().string() == path.root_name().string() && + util::starts_with(pp, path)) { return true; + } } return false; diff --git a/src/common/model/source_file.h b/src/common/model/source_file.h index dd171bfe..108e29ec 100644 --- a/src/common/model/source_file.h +++ b/src/common/model/source_file.h @@ -37,7 +37,11 @@ namespace clanguml::common::model { enum class source_file_t { kDirectory, kHeader, kImplementation }; struct fs_path_sep { +#ifdef _WIN32 + static constexpr std::string_view value = "\\"; +#else static constexpr std::string_view value = "/"; +#endif }; using filesystem_path = common::model::path; @@ -107,7 +111,7 @@ public: res /= name(); if (is_absolute_) - res = "/" / res; + res = fs_path_sep::value / res; else res = base / res; diff --git a/src/config/config.cc b/src/config/config.cc index d6061fb6..1db24d1c 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -599,7 +599,7 @@ template <> struct convert { // Ensure relative_to has a value if (!rhs.relative_to.has_value) - rhs.relative_to.set(std::filesystem::current_path()); + rhs.relative_to.set(std::filesystem::current_path().lexically_normal()); rhs.initialize_type_aliases();