class DirWatcher

Defined at line 106 of file ../../sdk/lib/device-watcher/cpp/device-watcher.h

DirWatcher can be used to detect when a file has been removed from the filesystem.

Example usage:

std::unique_ptr

<DirWatcher

> watcher;

zx_status_t status = DirWatcher::Create(dir_fd,

&watcher

);

...

// Trigger removal of file here.

...

status = watcher->WaitForRemoval(filename, deadline);

Public Methods

zx_status_t Create (int dir_fd, std::unique_ptr<DirWatcher> * out_dir_watcher)

Creates a new |DirWatcher| instance to watch the directory represented by |dir_fd|.

This method does not take ownership of |dir_fd|.

Defined at line 49 of file ../../sdk/lib/device-watcher/cpp/device-watcher.cc

zx::result<DirWatcher> Create (fidl::UnownedClientEnd<fuchsia_io::Directory> dir)

Creates a new |DirWatcher| instance to watch the directory |dir| is connected to..

Defined at line 40 of file ../../sdk/lib/device-watcher/cpp/device-watcher.cc

zx_status_t WaitForRemoval (std::string_view filename, zx::duration timeout)

Returns ZX_OK if |filename| is removed from the directory before the given timeout elapses.

If no filename is specified, this will wait for any file in the directory to be removed.

TODO(https://fxbug.dev/42068369): Remove `timeout`.

Defined at line 61 of file ../../sdk/lib/device-watcher/cpp/device-watcher.cc

void DirWatcher (fidl::ClientEnd<fuchsia_io::DirectoryWatcher> client)

Users should call Create instead. This is public for make_unique.

Defined at line 116 of file ../../sdk/lib/device-watcher/cpp/device-watcher.h