Expand description
Upstream: https://github.com/rust-lang/cargo/blob/rust-1.83.0/crates/cargo-util/src/paths.rs Various utilities for working with files and paths.
Structs§
- Path
Ancestors - An iterator that walks up the directory hierarchy towards the root.
Functions§
- ancestors
- Returns an iterator that walks up the directory hierarchy towards the root.
- append
- Equivalent to
write()
, but appends to the end instead of replacing the contents. - bytes2path
- Converts UTF-8 bytes to a path.
- copy
- Copies a file from one location to another.
- create
- Creates a new file.
- create_
dir_ all - Equivalent to
std::fs::create_dir_all
with better error messages. - create_
dir_ all_ excluded_ from_ backups_ atomic - Creates an excluded from cache directory atomically with its parents as needed.
- dylib_
path - Returns a list of directories that are searched for dynamic libraries.
- dylib_
path_ envvar - Returns the name of the environment variable used for searching for dynamic libraries.
- exclude_
from_ backups_ and_ indexing - Mark an existing directory as excluded from backups and indexing.
- join_
paths - Joins paths into a string suitable for the
PATH
environment variable. - link_
or_ copy - Hardlink (file) or symlink (dir) src to dst if possible, otherwise copy it.
- metadata
- Returns metadata for a file (follows symlinks).
- normalize_
path - Normalize a path, removing things like
.
and..
. - open
- Opens an existing file.
- path2bytes
- Converts a path to UTF-8 bytes.
- read
- Reads a file to a string.
- read_
bytes - Reads a file into a bytes vector.
- remove_
dir - Equivalent to
std::fs::remove_dir
with better error messages. - remove_
dir_ all - Equivalent to
std::fs::remove_dir_all
with better error messages. - remove_
file - Equivalent to
std::fs::remove_file
with better error messages. - resolve_
executable - Returns the absolute path of where the given executable is located based
on searching the
PATH
environment variable. - strip_
prefix_ canonical - Strips
base
frompath
. - symlink_
metadata - Returns metadata for a file without following symlinks.
- temp_
dir_ in - Creates a temporary directory in the given path and calls the given function.
- write
- Writes a file to disk.
- write_
atomic - Writes a file to disk atomically.
- write_
if_ changed - Equivalent to
write()
, but does not write anything if the file contents are identical to the given contents.