pub async fn set_permissions<P: AsRef<Path>>(
    path: P,
    perm: Permissions
) -> Result<()>
Expand description

Changes the permissions of a file or directory.

Errors

An error will be returned in the following situations:

  • path does not point to an existing file or directory.
  • The current process lacks permissions to change attributes on the file or directory.
  • Some other I/O error occurred.

Examples

let mut perm = async_fs::metadata("a.txt").await?.permissions();
perm.set_readonly(true);
async_fs::set_permissions("a.txt", perm).await?;