|
| 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. More...
|
|
virtual result< bool > | pre_enumeration (void *data, const directory_handle &dirh, size_t depth) noexcept |
| Called to decide whether to enumerate a directory. More...
|
|
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. More...
|
|
A visitor for the filesystem contents algorithm.
virtual result<bool> llfio_v2_xxx::algorithm::traverse_visitor::pre_enumeration |
( |
void * |
data, |
|
|
const directory_handle & |
dirh, |
|
|
size_t |
depth |
|
) |
| |
|
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
.
- Note
- May be called from multiple kernel threads concurrently.
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.
227 if(visitor ==
nullptr)
229 visitor = &default_visitor;
231 contents_visitor::_state_type state(dirh);
232 OUTCOME_TRY(
auto &&dirhpath, dirh.current_path());
233 state.rootdirpathlen.store(dirhpath.native().size() + 1, std::memory_order_relaxed);
234 OUTCOME_TRY(
traverse(dirh, visitor, threads, &state, force_slow_path));
235 return {std::move(state.contents)};
result< size_t > traverse(const path_handle &dirh, traverse_visitor *visitor, size_t threads=0, void *data=nullptr, bool force_slow_path=false) noexcept
Traverse everything within and under dirh.
contents_visitor()=default
Default construtor.