LLFIO v2.00
|
A visitor for the filesystem contents algorithm. More...
#include "contents.hpp"
Classes | |
struct | _state_type |
struct | contents_type |
Enumerated contents, and what parts of their stat_t is valid. More... | |
Public Member Functions | |
contents_visitor ()=default | |
Default construtor. | |
contents_visitor (stat_t::want _metadata, bool _include_files=true, bool _include_directories=true, bool _include_symlinks=true) | |
Construct an instance. | |
virtual result< void > | post_enumeration (void *data, const directory_handle &dirh, directory_handle::buffers_type &contents, size_t depth) noexcept |
The default implementation accumulates the contents into thread local storage. At traverse end, all the thread local storages are coalesced into a single result, the member variable contents . | |
virtual result< size_t > | finished (void *data, result< size_t > result) noexcept |
Called when a traversal finishes, this default implementation merges all the thread local results into contents , and deallocates the thread local results. | |
virtual result< directory_handle > | directory_open_failed (void *data, result< void >::error_type &&error, const directory_handle &dirh, path_view leaf, size_t depth) noexcept |
Called when we failed to open a directory for enumeration. The default fails the traversal with that error. Return a default constructed instance to ignore the failure. | |
virtual result< bool > | pre_enumeration (void *data, const directory_handle &dirh, size_t depth) noexcept |
Called to decide whether to enumerate a directory. | |
virtual result< void > | stack_updated (void *data, size_t dirs_processed, size_t known_dirs_remaining, size_t depth_processed, size_t known_depth_remaining) noexcept |
Called whenever the traversed stack of directory hierarchy is updated. This can act as an estimated progress indicator, or to give an accurate progress indicator by matching it against a previous traversal. | |
Public Attributes | |
bool | contents_include_files {true} |
Whether to include files in the contents. | |
bool | contents_include_directories {true} |
Whether to include directories in the contents. | |
bool | contents_include_symlinks {true} |
Whether to include symlinks in the contents. | |
stat_t::want | contents_include_metadata {stat_t::want::none} |
What stat_t::want to include, if enumeration doesn't provide these, they will be additionally fetched. | |
Static Protected Member Functions | |
static std::shared_ptr< contents_type > | _thread_contents (_state_type *state) noexcept |
Friends | |
result< contents_type > | contents (const path_handle &dirh, contents_visitor *visitor, size_t threads, bool force_slow_path) noexcept |
Calculate the contents of everything within and under dirh . What is returned is unordered. | |
A visitor for the filesystem contents algorithm.
|
inlineexplicit |
Construct an instance.
|
inlinestaticprotectednoexcept |
|
inlinevirtualnoexceptinherited |
Called when we failed to open a directory for enumeration. The default fails the traversal with that error. Return a default constructed instance to ignore the failure.
Reimplemented in llfio_v2_xxx::algorithm::reduce_visitor, and llfio_v2_xxx::algorithm::summarize_visitor.
|
inlinevirtualnoexcept |
Called when a traversal finishes, this default implementation merges all the thread local results into contents
, and deallocates the thread local results.
Reimplemented from llfio_v2_xxx::algorithm::traverse_visitor.
|
inlinevirtualnoexcept |
The default implementation accumulates the contents into thread local storage. At traverse end, all the thread local storages are coalesced into a single result, the member variable contents
.
Reimplemented from llfio_v2_xxx::algorithm::traverse_visitor.
|
inlinevirtualnoexceptinherited |
Called to decide whether to enumerate a directory.
Note that it is more efficient to ignore the directory entry in post_enumeration()
than to ignore it here, as a handle is opened for the directory before this callback. Equally, if you need that handle to inspect the directory e.g. to check if one is entering a different filesystem from the root, here is best.
The default returns true
.
|
inlinevirtualnoexceptinherited |
Called whenever the traversed stack of directory hierarchy is updated. This can act as an estimated progress indicator, or to give an accurate progress indicator by matching it against a previous traversal.
data | The third party data pointer passed to traverse() . |
dirs_processed | The total number of directories traversed so far. |
known_dirs_remaining | The currently known number of directories awaiting traversal. |
depth_processed | How many levels deep we have already completely traversed. |
known_depth_remaining | The currently known number of levels we shall traverse. |
|
friend |
Calculate the contents of everything within and under dirh
. What is returned is unordered.
This is a very thin veneer over traverse()
which came out of the fact that I kept writing "get me the contents" traversal visitors again and again, so eventually I just wrote a library edition. Its only "clever" bit is that it stores the contents in thread local storage, and merges the contents afterwards.
It is race free to concurrent relocations of dirh
. It is entirely implemented in header-only code, as it is very simple.
bool llfio_v2_xxx::algorithm::contents_visitor::contents_include_directories {true} |
Whether to include directories in the contents.
bool llfio_v2_xxx::algorithm::contents_visitor::contents_include_files {true} |
Whether to include files in the contents.
stat_t::want llfio_v2_xxx::algorithm::contents_visitor::contents_include_metadata {stat_t::want::none} |
What stat_t::want
to include, if enumeration doesn't provide these, they will be additionally fetched.
bool llfio_v2_xxx::algorithm::contents_visitor::contents_include_symlinks {true} |
Whether to include symlinks in the contents.