[][src]Module bdrck::fs

fs provides various utilities for interacting with the filesystem.

Functions

create_file

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.

create_symlink

An implementation of a function to create symbolic links on UNIX-style OSes. This works equivalently to "ln -s target symlink".

path_from_bytes

Construct a PathBuf from its byte representation, for example as returned by path_to_bytes.

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.

set_ownership

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_ownership_by_name

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_permissions_mode

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).