Function rs_utils::file::file_new_append [] [src]

pub fn file_new_append(file_path: &Path) -> Result<File, Error>

Opens a new file at specified path for writing in append mode, recursively creating parent directories

Errors

let e = file_new_append (Path::new ("somepath/")).err().unwrap();
assert_eq!(e.kind(), ErrorKind::InvalidInput);
assert_eq!(e.description(), "not a file");
extern crate tempdir;

let temp_dir = tempdir::TempDir::new_in ("", "tmp").unwrap();
let file_path = temp_dir.path().join (Path::new ("somefile"));
let file_path = file_path.as_path();
assert! (!file_path.exists());
file_new_append (file_path).unwrap();
let e = file_new_append (file_path).err().unwrap();
assert_eq!(e.kind(), ErrorKind::AlreadyExists);
assert_eq!(e.description(), "entity already exists");