[−][src]Function stdbench::ensure_parent_exists
pub fn ensure_parent_exists(path: &Path) -> Result<(), Error>
If the parent directory of path
does not exist, create it.
Examples
assert_eq!( ensure_parent_exists(Path::new("/")), Err(Error::from("cannot access parent of path: /")) ); let tmp = TempDir::new("parent_exists").unwrap(); let parent = tmp.path().join("parent"); let child = parent.join("child"); assert!(ensure_parent_exists(child.as_path()).is_ok()); assert!(parent.exists());