Module cargo_util::paths
source · Expand description
Various utilities for working with files and paths.
Structs
Functions
- Returns an iterator that walks up the directory hierarchy towards the root.
- Equivalent to
write()
, but appends to the end instead of replacing the contents. - Converts UTF-8 bytes to a path.
- Copies a file from one location to another.
- Creates a new file.
- Equivalent to
std::fs::create_dir_all
with better error messages. - Creates an excluded from cache directory atomically with its parents as needed.
- Returns a list of directories that are searched for dynamic libraries.
- Returns the name of the environment variable used for searching for dynamic libraries.
- Marks the directory as excluded from archives/backups.
- Mark an existing directory as excluded from backups and indexing.
- Marks the directory as excluded from content indexing.
- Marks files or directories as excluded from Time Machine on macOS
- Joins paths into a string suitable for the
PATH
environment variable. - Hardlink (file) or symlink (dir) src to dst if possible, otherwise copy it.
- Returns metadata for a file (follows symlinks).
- Returns the last modification time of a file.
- Returns the maximum mtime of the given path, recursing into subdirectories, and following symlinks.
- Normalize a path, removing things like
.
and..
. - Opens an existing file.
- Converts a path to UTF-8 bytes.
- Reads a file to a string.
- Reads a file into a bytes vector.
- Equivalent to
std::fs::remove_dir
with better error messages. - Equivalent to
std::fs::remove_dir_all
with better error messages. - Equivalent to
std::fs::remove_file
with better error messages. - Returns the absolute path of where the given executable is located based on searching the
PATH
environment variable. - Changes the filesystem mtime (and atime if possible) for the given file.
- Record the current time on the filesystem (using the filesystem’s clock) using a file at the given directory. Returns the current time.
- Strips
base
frompath
. - Returns metadata for a file without following symlinks.
- Writes a file to disk.
- Writes a file to disk atomically.
- Equivalent to
write()
, but does not write anything if the file contents are identical to the given contents.