From 9e7b13c7c253f3c3c13574a799f8e5b353a09d99 Mon Sep 17 00:00:00 2001 From: Furisto <24721048+Furisto@users.noreply.github.com> Date: Thu, 1 Jul 2021 22:25:23 +0200 Subject: [PATCH] Provide context in case of errors during dir creation --- src/utils.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 1711de19..d5f0729f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -96,6 +96,11 @@ pub fn write_file, C: AsRef<[u8]>>(path: P, contents: C) -> Resul Ok(()) } +pub fn create_dir_all>(path: P) -> Result<()> { + let path = path.as_ref(); + fs::create_dir_all(path).with_context(|| format!("failed to create directory {:?}", path)) +} + pub struct TempDir { path: Option, }