[][src]Function fungus::sys::write_p

pub fn write_p<T: AsRef<Path>, U: AsRef<[u8]>>(
    path: T,
    data: U,
    mode: u32
) -> FuResult<()>

Wraps write allowing for setting the file's mode.

Examples

use fungus::prelude::*;

let tmpdir = PathBuf::from("tests/temp").abs().unwrap().mash("file_doc_write_p");
assert!(sys::remove_all(&tmpdir).is_ok());
let tmpfile = tmpdir.mash("file1");
assert!(sys::mkdir(&tmpdir).is_ok());
assert!(sys::write_p(&tmpfile, "this is a test", 0o666).is_ok());
assert_eq!(sys::readstring(&tmpfile).unwrap(), "this is a test");
assert_eq!(tmpfile.mode().unwrap(), 0o100666);
assert!(sys::remove_all(&tmpdir).is_ok());