[][src]Function fungus::sys::chmod_p

pub fn chmod_p<T: AsRef<Path>>(path: T) -> FuResult<Chmod>

Create Chmod options providing path expansion, globbing, recursion and error tracing while setting the mode. This function provides more control over options than the chmod function. Changes are not invoked until the chmod method is called. Symbolic links will have the target mode changed.

Examples

use fungus::prelude::*;

let tmpdir = PathBuf::from("tests/temp").abs().unwrap().mash("file_doc_chmod_p");
assert!(sys::remove_all(&tmpdir).is_ok());
let file1 = tmpdir.mash("file1");
assert!(sys::mkdir(&tmpdir).is_ok());
assert!(sys::touch(&file1).is_ok());
assert!(sys::chmod_p(&file1).unwrap().mode(0o644).chmod().is_ok());
assert_eq!(file1.mode().unwrap(), 0o100644);
assert!(sys::chmod_p(&file1).unwrap().mode(0o555).chmod().is_ok());
assert_eq!(file1.mode().unwrap(), 0o100555);
assert!(sys::remove_all(&tmpdir).is_ok());