Function std::fs::set_permissions [] [src]

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

Changes the permissions found on a file or a directory.

Examples

fn main() { fn foo() -> std::io::Result<()> { use std::fs; let mut perms = try!(fs::metadata("foo.txt")).permissions(); perms.set_readonly(true); try!(fs::set_permissions("foo.txt", perms)); Ok(()) } }
use std::fs;

let mut perms = try!(fs::metadata("foo.txt")).permissions();
perms.set_readonly(true);
try!(fs::set_permissions("foo.txt", perms));

Errors

This function will return an error if the provided path doesn't exist, if the process lacks permissions to change the attributes of the file, or if some other I/O error is encountered.