Skip to main content

Module fs

Module fs 

Source
Expand description

Files, directories, paths, temporary files, globs, traversal, and file watching, comparable to java.io, java.nio.file, and System.IO.

Re-exports§

pub use ::glob;
pub use ::notify;
pub use ::tempfile;
pub use ::walkdir;

Structs§

Components
An iterator over the Components of a Path.
DirBuilder
A builder used to create directories in various manners.
DirEntry
Entries returned by the ReadDir iterator.
File
An object providing access to an open file on the filesystem.
FileTimes
Representation of the various timestamps on a file.
FileType
A structure representing a type of file with accessors for each file type. It is returned by Metadata::file_type method.
Metadata
Metadata information about a file.
OpenOptions
Options and flags which can be used to configure how a file is opened.
Path
A slice of a path (akin to str).
PathBuf
An owned, mutable path (akin to String).
Permissions
Representation of the various permissions on a file.
PrefixComponent
A structure wrapping a Windows path prefix as well as its unparsed string representation.
ReadDir
Iterator over the entries in a directory.
DirExperimental
An object providing access to a directory on the filesystem.
HomeDirsExperimental
Common user directory paths used for user-specific application files.
MediaDirsExperimental
Common user directory paths used for user-specific media files.

Enums§

Component
A single component of a path.
Prefix
Windows path prefixes, e.g., C: or \\server\share.
TryLockError
An enumeration of possible errors which can occur while trying to acquire a lock from the try_lock method and try_lock_shared method on a File.

Functions§

canonicalize
Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.
copy
Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.
create_dir
Creates a new, empty directory at the provided path.
create_dir_all
Recursively create a directory and all of its parent components if they are missing.
exists
Returns Ok(true) if the path points at an existing entity.
hard_link
Creates a new hard link on the filesystem.
metadata
Given a path, queries the file system to get information about a file, directory, etc.
read
Reads the entire contents of a file into a bytes vector.
read_dir
Returns an iterator over the entries within a directory.
read_link
Reads a symbolic link, returning the file that the link points to.
read_to_string
Reads the entire contents of a file into a string.
remove_dir
Removes an empty directory.
remove_dir_all
Removes a directory at this path, after removing all its contents. Use carefully!
remove_file
Removes a file from the filesystem.
rename
Renames a file or directory to a new name, replacing the original file if to already exists.
set_permissions
Changes the permissions found on a file or a directory.
set_times
Changes the timestamps of the file or directory at the specified path.
set_times_nofollow
Changes the timestamps of the file or symlink at the specified path.
soft_linkDeprecated
Creates a new symbolic link on the filesystem.
symlink_metadata
Queries the metadata about a file without following symlinks.
write
Writes a slice as the entire contents of a file.
rename_noreplaceExperimental
Renames a file or directory to a new name, returning AlreadyExists if to already exists.
set_permissions_nofollowExperimental
Changes the permissions found on a file or a directory. On certain platforms, if the file is a symlink, it will change the permissions bits on the symlink itself rather than the target (e.g. Windows, BSD, MacOS). On other platforms, this results in an error when attempting to change permissions on a symlink (e.g. Linux).