Module bdrck::fs

source ·
Expand description

fs provides various utilities for interacting with the filesystem.

Functions

  • This is a simple utility to create a new empty file. If a file at the given path already exists, it will be truncated. It’s an error if the path already exists but is, for example, a directory.
  • An implementation of a function to create symbolic links on UNIX-style OSes. This works equivalently to “ln -s target symlink”.
  • Construct a PathBuf from its byte representation, for example as returned by path_to_bytes.
  • Returns the given Path as a byte vector. This function may be useful for some kinds of serialization, or for calling C functions.
  • This function is a safe wrapper around chown(). If fail_on_access_denied is set to true, then an EACCES error is considered a failure, and we’ll return Err(…). Otherwise, this is considered a soft failure, and a warning will be logged, but Ok(()) will still be returned.
  • Set the user and group ownership of a file or directory. This is a convenience wrapper around set_ownership which allows the user and group to be specified by name instead of by ID.
  • Set the permissions mode for the given file or directory. This is roughly equivalent to chmod(2) on Linux. Note that UNIX-style systems do not support changing mode for a symlink itself, so this function always follows symlinks (see man 2 fchmodat for details).