directory_lister: add ctor with opened directory

This ctor allows the caller to open the directory first,
on its own, and pass it down to the directory_lister.

Once all callers use this ctor we can get rid of
the delayed open in the get() method.

Also, in can be used to replace full-path based file_stat calls
on listed entries with file_stat(directory, name) calls
that are based on statat() and a relative path name that is present
in the listed directory entry.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>

sq
This commit is contained in:
Benny Halevy
2026-01-04 09:49:51 +02:00
parent 6c8ddfc018
commit 8d00266f88

View File

@@ -196,6 +196,18 @@ public:
, _do_show_hidden(do_show_hidden)
{ }
directory_lister(file opened_directory, fs::path dir,
lister::dir_entry_types type = lister::dir_entry_types::full(),
lister::filter_type filter = [] (const fs::path& parent_dir, const directory_entry& entry) { return true; },
lister::show_hidden do_show_hidden = lister::show_hidden::yes) noexcept
: _dir(std::move(dir))
, _type(type)
, _filter(std::move(filter))
, _do_show_hidden(do_show_hidden)
, _opened(std::move(opened_directory))
, _gen(_opened.experimental_list_directory())
{ }
directory_lister(directory_lister&&) noexcept = default;
~directory_lister();