diff --git a/include/dwarfs/entry.h b/include/dwarfs/entry.h index 0802fb80..4a6e05e4 100644 --- a/include/dwarfs/entry.h +++ b/include/dwarfs/entry.h @@ -77,6 +77,7 @@ class entry : public entry_interface { std::filesystem::path fs_path() const; std::string path_as_string() const override; std::string dpath() const override; + std::string unix_dpath() const override; std::string const& name() const override { return name_; } size_t size() const override { return stat_.size; } virtual type_t type() const = 0; diff --git a/include/dwarfs/entry_interface.h b/include/dwarfs/entry_interface.h index 8297ee70..399fefc7 100644 --- a/include/dwarfs/entry_interface.h +++ b/include/dwarfs/entry_interface.h @@ -31,6 +31,7 @@ class entry_interface : public object { public: virtual std::string path_as_string() const = 0; virtual std::string dpath() const = 0; + virtual std::string unix_dpath() const = 0; virtual std::string const& name() const = 0; virtual std::string type_string() const = 0; virtual size_t size() const = 0; diff --git a/src/dwarfs/builtin_script.cpp b/src/dwarfs/builtin_script.cpp index f0e7d098..77271c23 100644 --- a/src/dwarfs/builtin_script.cpp +++ b/src/dwarfs/builtin_script.cpp @@ -244,7 +244,7 @@ void builtin_script_::add_filter_rules( template bool builtin_script_::filter(entry_interface const& ei) { - std::string path = ei.dpath(); + std::string path = ei.unix_dpath(); std::string relpath = path; if (relpath.size() >= root_path_.size()) { diff --git a/src/dwarfs/entry.cpp b/src/dwarfs/entry.cpp index 7ec2f31e..3cb8f444 100644 --- a/src/dwarfs/entry.cpp +++ b/src/dwarfs/entry.cpp @@ -83,6 +83,20 @@ std::string entry::dpath() const { return p; } +std::string entry::unix_dpath() const { + auto p = name_; + + if (type() == E_DIR) { + p += '/'; + } + + if (auto parent = parent_.lock()) { + return parent->unix_dpath() + p; + } + + return p; +} + std::string entry::type_string() const { switch (stat_.type()) { case posix_file_type::regular: