Module compiler

io::fs

Functions that inspect the file system (exists, metadata, list_dir, realpath, …) need --allow-read; those that create, remove or rename need --allow-write, and copy needs both. See Permissions.

There is no whole-file read or write here: use io::file (read_text, write_bytes, …) or open a stream with io::open. The stdlib path module wraps these functions in a Path value.

Built into the compiler.

Import what you use (use path::* is not allowed):

use io::fs::{copy, create_dir};

Functions#

NameDescription
copyCopies the contents of file from to to, creating or overwriting to.
create_dirCreates the directory path.
create_dir_allCreates the directory path and any missing parent directories.
existsReturns whether anything exists at path.
is_dirReturns whether path is a directory, following symbolic links.
is_fileReturns whether path is a regular file, following symbolic links.
is_symlinkReturns whether path itself is a symbolic link (the link is not followed).
list_dirReturns the names of the entries in directory path, sorted.
metadataReturns facts about path as a record, without following a final symbolic link.
read_linkReturns the target stored in the symbolic link at path.
realpathReturns the canonical absolute form of path, with every symbolic link, . and .. resolved.
remove_dirRemoves the empty directory path.
remove_dir_allRemoves the directory path and everything inside it.
remove_fileRemoves the file (or symbolic link) at path.
renameRenames (moves) from to to, replacing to if it is a file.
symlinkCreates a symbolic link at link that points to target.
↑ ↓ navigate ↵ open