mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 04:50:31 -04:00
Add unix_dpath() for filter rules
This commit is contained in:
parent
9163c6e24e
commit
65862e790f
@ -77,6 +77,7 @@ class entry : public entry_interface {
|
|||||||
std::filesystem::path fs_path() const;
|
std::filesystem::path fs_path() const;
|
||||||
std::string path_as_string() const override;
|
std::string path_as_string() const override;
|
||||||
std::string dpath() const override;
|
std::string dpath() const override;
|
||||||
|
std::string unix_dpath() const override;
|
||||||
std::string const& name() const override { return name_; }
|
std::string const& name() const override { return name_; }
|
||||||
size_t size() const override { return stat_.size; }
|
size_t size() const override { return stat_.size; }
|
||||||
virtual type_t type() const = 0;
|
virtual type_t type() const = 0;
|
||||||
|
@ -31,6 +31,7 @@ class entry_interface : public object {
|
|||||||
public:
|
public:
|
||||||
virtual std::string path_as_string() const = 0;
|
virtual std::string path_as_string() const = 0;
|
||||||
virtual std::string dpath() 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 const& name() const = 0;
|
||||||
virtual std::string type_string() const = 0;
|
virtual std::string type_string() const = 0;
|
||||||
virtual size_t size() const = 0;
|
virtual size_t size() const = 0;
|
||||||
|
@ -244,7 +244,7 @@ void builtin_script_<LoggerPolicy>::add_filter_rules(
|
|||||||
|
|
||||||
template <typename LoggerPolicy>
|
template <typename LoggerPolicy>
|
||||||
bool builtin_script_<LoggerPolicy>::filter(entry_interface const& ei) {
|
bool builtin_script_<LoggerPolicy>::filter(entry_interface const& ei) {
|
||||||
std::string path = ei.dpath();
|
std::string path = ei.unix_dpath();
|
||||||
std::string relpath = path;
|
std::string relpath = path;
|
||||||
|
|
||||||
if (relpath.size() >= root_path_.size()) {
|
if (relpath.size() >= root_path_.size()) {
|
||||||
|
@ -83,6 +83,20 @@ std::string entry::dpath() const {
|
|||||||
return p;
|
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 {
|
std::string entry::type_string() const {
|
||||||
switch (stat_.type()) {
|
switch (stat_.type()) {
|
||||||
case posix_file_type::regular:
|
case posix_file_type::regular:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user