Module directory

Source
Expand description

Utility functions for fuchsia.io directories.

Structs§

DirEntry
A directory entry.
WatchEvent
Describes the type of event that occurred in the directory being watched.
WatchMessage
A message containing a WatchEvent and the filename (relative to the directory being watched) that triggered the event.
Watcher
Provides a Stream of WatchMessages corresponding to filesystem events for a given directory. After receiving an error, the stream will return the error, and then will terminate. After it’s terminated, the stream is fused and will continue to return None when polled.

Enums§

DecodeDirentError
An error encountered while decoding a single directory entry.
DirentKind
EnumerateError
Error returned by readdir.
RecursiveEnumerateError
Error returned by readdir_recursive.
WatcherCreateError
WatcherStreamError

Functions§

clone
Opens a new connection to the given directory. The cloned connection has the same permissions.
clone_onto
Opens a new connection to the given directory using request. The cloned connection has the same permissions as directory.
close
Gracefully closes the directory proxy from the remote end.
create_directory
Creates a directory named path within the parent directory if it doesn’t exist.
create_directory_recursive
Creates a directory named path (including all segments leading up to the terminal segment) within the parent directory. Returns a connection to the terminal directory.
create_randomly_named_file
Create a randomly named file in the given directory with the given prefix, and return its path and FileProxy. prefix may contain “/”.
dir_contains
Returns true if an entry with the specified name exists in the given directory.
dir_contains_with_timeout
Returns true if an entry with the specified name exists in the given directory.
open_async
Opens the given path from the given parent directory as a [P::Proxy]. The target is not verified to be any particular type and may not implement the [P] protocol.
open_channel_in_namespace
Asynchronously opens the given [path] in the current namespace, serving the connection over [request]. Once the channel is connected, any calls made prior are serviced.
open_directory
Opens the given path from given parent directory as a [DirectoryProxy], verifying that the target implements the fuchsia.io.Directory protocol.
open_directory_async
Opens the given path from the given parent directory as a [DirectoryProxy]. If open fails, the returned DirectoryProxy will be closed with an epitaph.
open_file
Opens the given path from given parent directory as a [FileProxy], verifying that the target implements the fuchsia.io.File protocol.
open_file_async
Opens the given path from the given parent directory as a [FileProxy]. If open fails, the returned FileProxy will be closed with an epitaph.
open_in_namespace
Opens the given path from the current namespace as a [DirectoryProxy].
open_node
Opens the given path from the given parent directory as a [NodeProxy], verifying that the target implements the fuchsia.io.Node protocol.
parse_dir_entries
Parses the buffer returned by a read_dirents FIDL call.
read_file
Opens path from the parent directory as a file and reads the file contents into a Vec.
read_file_to_string
Opens path from the parent directory as a file and reads the file contents as a utf-8 encoded string.
readdir
Returns a sorted Vec of directory entries contained directly in the given directory proxy. The returned entries will not include “.” or nodes from any subdirectories.
readdir_inclusive
Returns a sorted Vec of directory entries contained directly in the given directory proxy. (Like readdir, but includes the dot path as well.)
readdir_recursive
Returns a Vec of all non-directory nodes and all empty directory nodes in the given directory proxy. The returned entries will not include “.”. |timeout| can be provided optionally to specify the maximum time to wait for a directory to be read.
readdir_recursive_filtered
Returns Stream of nodes in tree rooted at the given DirectoryProxy for which |results_filter| returns true plus any leaf (empty) directories. The results filter receives the directory entry for the node in question and if the node is a directory, a reference a Vec of the directory’s contents. The function recurses into sub-directories for which |recurse_filter| returns true. The returned entries will not include “.”. |timeout| can be provided optionally to specify the maximum time to wait for a directory to be read.
readdir_with_timeout
Returns a sorted Vec of directory entries contained directly in the given directory proxy. The returned entries will not include “.” or nodes from any subdirectories. Timeouts if the read takes longer than the given timeout duration.
remove_dir_recursive
Removes a directory and all of its children. name must be a subdirectory of root_dir.
rename
Rename src to dst under the given directory, src and dst may contain “/”.