[][src]Function skellige::prelude::sys::write_p

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

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());