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#
| Name | Description |
|---|---|
copy | Copies the contents of file from to to, creating or overwriting to. |
create_dir | Creates the directory path. |
create_dir_all | Creates the directory path and any missing parent directories. |
exists | Returns whether anything exists at path. |
is_dir | Returns whether path is a directory, following symbolic links. |
is_file | Returns whether path is a regular file, following symbolic links. |
is_symlink | Returns whether path itself is a symbolic link (the link is not followed). |
list_dir | Returns the names of the entries in directory path, sorted. |
metadata | Returns facts about path as a record, without following a final symbolic link. |
read_link | Returns the target stored in the symbolic link at path. |
realpath | Returns the canonical absolute form of path, with every symbolic link, . and .. resolved. |
remove_dir | Removes the empty directory path. |
remove_dir_all | Removes the directory path and everything inside it. |
remove_file | Removes the file (or symbolic link) at path. |
rename | Renames (moves) from to to, replacing to if it is a file. |
symlink | Creates a symbolic link at link that points to target. |